Skip to content

Instantly share code, notes, and snippets.

@yyoncho
Created March 17, 2021 17:28
Show Gist options
  • Save yyoncho/f872ab6a388199fe4e107cf782282fa5 to your computer and use it in GitHub Desktop.
Save yyoncho/f872ab6a388199fe4e107cf782282fa5 to your computer and use it in GitHub Desktop.
(defun lsp--client-capabilities (&optional custom-capabilities)
"Return the client capabilities appending CUSTOM-CAPABILITIES."
(append
`((workspace . ((workspaceEdit . ((documentChanges . t)
(resourceOperations . ["create" "rename" "delete"])))
(applyEdit . t)
(symbol . ((symbolKind . ((valueSet . ,(apply 'vector (number-sequence 1 26)))))))
(executeCommand . ((dynamicRegistration . :json-false)))
,@(when lsp-enable-file-watchers '((didChangeWatchedFiles . ((dynamicRegistration . t)))))
(workspaceFolders . t)
(configuration . t)))
(textDocument . ((declaration . ((linkSupport . t)))
(definition . ((linkSupport . t)))
(implementation . ((linkSupport . t)))
(typeDefinition . ((linkSupport . t)))
(synchronization . ((willSave . t) (didSave . t) (willSaveWaitUntil . t)))
(documentSymbol . ((symbolKind . ((valueSet . ,(apply 'vector (number-sequence 1 26)))))
(hierarchicalDocumentSymbolSupport . t)))
(formatting . ((dynamicRegistration . t)))
(rangeFormatting . ((dynamicRegistration . t)))
,@(when (and lsp-semantic-tokens-enable
(boundp 'lsp-semantic-tokens-capabilities))
lsp-semantic-tokens-capabilities)
(rename . ((dynamicRegistration . t) (prepareSupport . t)))
(codeAction . ((dynamicRegistration . t)
(isPreferredSupport . t)
(codeActionLiteralSupport . ((codeActionKind . ((valueSet . [""
"quickfix"
"refactor"
"refactor.extract"
"refactor.inline"
"refactor.rewrite"
"source"
"source.organizeImports"])))))
(resolveSupport . ((properties . ["edit" "command"])))
(dataSupport . t)))
(completion . ((completionItem . ((snippetSupport . ,(cond
((and lsp-enable-snippet (not (featurep 'yasnippet)) t)
(lsp--warn (concat
"Yasnippet is not installed, but `lsp-enable-snippet' is set to `t'. "
"You must either install yasnippet, or disable snippet support."))
:json-false)
(lsp-enable-snippet t)
(t :json-false)))
(documentationFormat . ["markdown"])
;; Remove this after jdtls support resolveSupport
(resolveAdditionalTextEditsSupport . t)
(resolveSupport
. ((properties . ["documentation"
"details"
"additionalTextEdits"
"command"])))))
(contextSupport . t)))
(signatureHelp . ((signatureInformation . ((parameterInformation . ((labelOffsetSupport . t)))))))
(documentLink . ((dynamicRegistration . t)
(tooltipSupport . t)))
(hover . ((contentFormat . ["markdown" "plaintext"])))
,@(when lsp-enable-folding
`((foldingRange . ((dynamicRegistration . t)
,@(when lsp-folding-range-limit
`((rangeLimit . ,lsp-folding-range-limit)))
,@(when lsp-folding-line-folding-only
`((lineFoldingOnly . t)))))))
(callHierarchy . ((dynamicRegistration . :json-false)))
(publishDiagnostics . ((relatedInformation . t)
(tagSupport . ((valueSet . [1 2])))
(versionSupport . t)))))
(window . ((workDoneProgress . t))))
custom-capabilities))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment