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

Add support for a completion item label details #3495

Merged
merged 2 commits into from
Apr 30, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.org
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
* Add support for ~typescript-language-server~’s inlay hints.
* Add support for ~workspace/willRenameFiles~ and ~workspace/didRenameFiles~.
* Improve project root import to read specific keys instead of any events.
* Support ~labelDetails~ of Lsp Specification 3.17
** Release 8.0.0
* Add ~lsp-clients-angular-node-get-prefix-command~ to get the Angular server from another location which is still has ~/lib/node_modules~ in it.
* Set ~lsp-clients-angular-language-server-command~ after the first connection to speed up subsequent connections.
Expand Down
11 changes: 10 additions & 1 deletion lsp-completion.el
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,12 @@ ignored."
:type 'boolean
:group 'lsp-completion)

(defcustom lsp-completion-show-label-description t
"Whether or not to show description of completion candidates."
:type 'boolean
:group 'lsp-completion
:package-version '(lsp-mode . "8.0.1"))

(defcustom lsp-completion-no-cache nil
"Whether or not caching the returned completions from server."
:type 'boolean
Expand Down Expand Up @@ -164,10 +170,13 @@ This will help minimize popup flickering issue in `company-mode'."

(defun lsp-completion--annotate (item)
"Annotate ITEM detail."
(-let (((&CompletionItem :detail? :kind?) (plist-get (text-properties-at 0 item)
(-let (((&CompletionItem :detail? :kind? :label-details?) (plist-get (text-properties-at 0 item)
'lsp-completion-item)))
(concat (when (and lsp-completion-show-detail detail?)
(concat " " (s-replace "\r" "" detail?)))
(when (and lsp-completion-show-label-description label-details?)
(when-let ((description (and label-details? (gethash "description" label-details?))))
jadestrong marked this conversation as resolved.
Show resolved Hide resolved
(format " %s" description)))
(when lsp-completion-show-kind
(when-let ((kind-name (and kind? (aref lsp-completion--item-kind kind?))))
(format " (%s)" kind-name))))))
Expand Down
2 changes: 1 addition & 1 deletion lsp-protocol.el
Original file line number Diff line number Diff line change
Expand Up @@ -584,7 +584,7 @@ See `-let' for a description of the destructuring mechanism."
(Command (:title :command) (:arguments))
(CompletionCapabilities nil (:completionItem :completionItemKind :contextSupport :dynamicRegistration))
(CompletionContext (:triggerKind) (:triggerCharacter))
(CompletionItem (:label) (:additionalTextEdits :command :commitCharacters :data :deprecated :detail :documentation :filterText :insertText :insertTextFormat :insertTextMode :kind :preselect :sortText :tags :textEdit :score))
(CompletionItem (:label) (:additionalTextEdits :command :commitCharacters :data :deprecated :detail :documentation :filterText :insertText :insertTextFormat :insertTextMode :kind :preselect :sortText :tags :textEdit :score :labelDetails))
(CompletionItemCapabilities nil (:commitCharactersSupport :deprecatedSupport :documentationFormat :preselectSupport :snippetSupport :tagSupport :insertReplaceSupport :resolveSupport))
(CompletionItemKindCapabilities nil (:valueSet))
(CompletionItemTagSupportCapabilities (:valueSet) nil)
Expand Down