branch: externals/eglot commit ef80455416426fea7bd4e80797365c5ed18bd66f Author: João Távora <joaotav...@gmail.com> Commit: João Távora <joaotav...@gmail.com>
Support :completionItem/resolve This is quite handy with company and company-quickhelp * eglot.el (eglot-completion-at-point): Send :completionItem/resolve * README.md: Mention completionItem/resolve --- README.md | 3 ++- eglot.el | 38 +++++++++++++++++++++++++------------- 2 files changed, 27 insertions(+), 14 deletions(-) diff --git a/README.md b/README.md index c2931be..8a94466 100644 --- a/README.md +++ b/README.md @@ -74,7 +74,7 @@ server. To skip the guess and always be prompted use `C-u M-x eglot`. ## Language features - [x] textDocument/completion -- [ ] completionItem/resolve +- [x] completionItem/resolve (works quite well with [company-mode][company-mode]) - [x] textDocument/hover - [ ] textDocument/signatureHelp - [x] textDocument/definition @@ -144,5 +144,6 @@ Under the hood: [emacs-lsp]: https://github.com/emacs-lsp/lsp-mode [emacs-lsp-plugins]: https://github.com/emacs-lsp [bash-language-server]: https://github.com/mads-hartmann/bash-language-server +[company-mode]: https://github.com/company-mode/company-mode diff --git a/eglot.el b/eglot.el index 58a2374..3557303 100644 --- a/eglot.el +++ b/eglot.el @@ -1278,23 +1278,35 @@ DUMMY is ignored" :textDocument/completion)) (items (if (vectorp resp) resp (plist-get resp :items)))) (eglot--mapply - (eglot--lambda (&key insertText label kind detail - documentation sortText &allow-other-keys) - (propertize (or insertText label) - :kind-name (cdr (assoc kind eglot--kind-names)) - :detail detail - :documentation documentation :sortText sortText)) + (eglot--lambda (&rest all &key label &allow-other-keys) + (add-text-properties 0 1 all label) label) items)))) :annotation-function - (lambda (what) - (propertize (concat " " (or (get-text-property 0 :detail what) - (get-text-property 0 :kind what))) + (lambda (obj) + (propertize (concat " " (or (get-text-property 0 :detail obj) + (cdr (assoc (get-text-property 0 :kind obj) + eglot--kind-names)))) 'face 'font-lock-function-name-face)) :display-sort-function - (lambda (items) (sort items (lambda (a b) - (string-lessp - (get-text-property 0 :sortText a) - (get-text-property 0 :sortText b))))) + (lambda (items) + (sort items (lambda (a b) + (string-lessp + (or (get-text-property 0 :sortText a) "") + (or (get-text-property 0 :sortText b) ""))))) + :company-doc-buffer + (lambda (obj) + (let ((documentation + (or (get-text-property 0 :documentation obj) + (plist-get (eglot--request proc :completionItem/resolve + (text-properties-at 0 obj)) + :documentation)))) + (when documentation + (with-current-buffer (get-buffer-create " *eglot doc*") + (erase-buffer) + (ignore-errors (funcall (intern "markdown-mode"))) + (font-lock-ensure) + (insert documentation) + (current-buffer))))) :exit-function (lambda (_string _status) (eglot-eldoc-function))))))