Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pyright and :company-docsig #769

Closed
fbergroth opened this issue Dec 14, 2021 · 2 comments · Fixed by #771
Closed

Pyright and :company-docsig #769

fbergroth opened this issue Dec 14, 2021 · 2 comments · Fixed by #771

Comments

@fbergroth
Copy link
Contributor

One cool feature of pyright is that it gives completions in other modules and automatically inserts the import when committing such completions. Here I complete isinf from numpy (using corfu).

rec

Pyright is sending :data (... :autoImportText "from numpy import isinf" ...), so I had to do the following to get the stuff shown in the echo area:

@@ -2394,6 +2394,12 @@ is not active."
                      (kind (alist-get (plist-get lsp-item :kind)
                                       eglot--kind-names)))
            (intern (downcase kind))))
+       :company-docsig
+       (lambda (proxy)
+         (when-let* ((lsp-comp (get-text-property 0 'eglot--lsp-item proxy))
+                     (data (plist-get (funcall resolve-maybe lsp-comp) :data))
+                     (import-text (plist-get data :autoImportText)))
+           import-text))
        :company-doc-buffer
        (lambda (proxy)
          (let* ((documentation

Auto-import completions are not nearly as useful if you can't see where the symbol is coming from.

I understand that this is outside of the spec, but would it be possible to somehow support this?

@joaotavora
Copy link
Owner

Not sure I fully understand the problem, but supporting things outside the spec is fine as long as they don't clash with things inside the spec or other existing behaviour. Was company :docsig unused totally? if so, it doesn't clash with anyone, but leave at least a comment and a FIXME saying it is python-specific

fbergroth added a commit to fbergroth/eglot that referenced this issue Dec 15, 2021
* eglot.el (eglot-completion-at-point): show autoImportText via company-docsig.
@fbergroth
Copy link
Contributor Author

fbergroth commented Dec 15, 2021

The problem is that you don't really know if inf comes from numpy or math without seeing the autoImportText portion. It seems like corfu is dropping duplicates, otherwise there would be two indistinguishable completions for inf. Also it's nice to be able to see what module the completion-symbol is coming from.

Was company :docsig unused totally?

Yep.

if so, it doesn't clash with anyone, but leave at least a comment and a FIXME saying it is python-specific

Right, I opened a PR for this.

@skangas skangas linked a pull request Jan 9, 2022 that will close this issue
@skangas skangas reopened this Jan 11, 2022
skangas pushed a commit that referenced this issue Jan 11, 2022
* eglot.el (eglot-completion-at-point): show autoImportText via company-docsig.
bhankas pushed a commit to bhankas/emacs that referenced this issue Sep 18, 2022
…e server

* eglot.el (eglot-completion-at-point): show autoImportText via company-docsig.
bhankas pushed a commit to bhankas/emacs that referenced this issue Sep 19, 2022
…e server

* eglot.el (eglot-completion-at-point): show autoImportText via company-docsig.
bhankas pushed a commit to bhankas/emacs that referenced this issue Sep 19, 2022
* eglot.el (eglot-completion-at-point): show autoImportText via company-docsig.

#769: joaotavora/eglot#769
jollaitbot pushed a commit to sailfishos-mirror/emacs that referenced this issue Oct 12, 2022
* eglot.el (eglot-completion-at-point): show autoImportText via company-docsig.

GitHub-reference: fix joaotavora/eglot#769
jollaitbot pushed a commit to sailfishos-mirror/emacs that referenced this issue Oct 20, 2022
* eglot.el (eglot-completion-at-point): show autoImportText via company-docsig.

GitHub-reference: fix joaotavora/eglot#769
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants