endif
enddef
+var SupportedCheckFns = {
+ codeAction: (lspserver) => lspserver.isCodeActionProvider,
+ codeLens: (lspserver) => lspserver.isCodeLensProvider,
+ completion: (lspserver) => lspserver.isCompletionProvider,
+ declaration: (lspserver) => lspserver.isDeclarationProvider,
+ definition: (lspserver) => lspserver.isDefinitionProvider,
+ documentFormatting: (lspserver) => lspserver.isDocumentFormattingProvider,
+ documentHighlight: (lspserver) => lspserver.isDocumentHighlightProvider,
+ foldingRange: (lspserver) => lspserver.isFoldingRangeProvider,
+ hover: (lspserver) => lspserver.isHoverProvider,
+ implementation: (lspserver) => lspserver.isImplementationProvider,
+ references: (lspserver) => lspserver.isReferencesProvider,
+ rename: (lspserver) => lspserver.isRenameProvider,
+ selectionRange: (lspserver) => lspserver.isSelectionRangeProvider,
+ typeDefinition: (lspserver) => lspserver.isTypeDefinitionProvider,
+}
+
# Returns the LSP server for the buffer 'bnr' and optionally 'domain'.
# Returns an empty dict if the server is not found.
export def BufLspServerGet(bnr: number, domain: string = null_string): dict<any>
return bufnrToServers[bnr][0]
endif
- var SupportedCheckFns = {
- 'completion': (lspserver) => lspserver.isCompletionProvider,
- 'definition': (lspserver) => lspserver.isDefinitionProvider,
- 'declaration': (lspserver) => lspserver.isDeclarationProvider,
- 'typeDefinition': (lspserver) => lspserver.isTypeDefinitionProvider,
- 'implementation': (lspserver) => lspserver.isImplementationProvider,
- 'hover': (lspserver) => lspserver.isHoverProvider,
- 'references': (lspserver) => lspserver.isReferencesProvider,
- 'documentHighlight': (lspserver) => lspserver.isDocumentHighlightProvider,
- 'documentFormatting': (lspserver) => lspserver.isDocumentFormattingProvider,
- 'rename': (lspserver) => lspserver.isRenameProvider,
- 'codeAction': (lspserver) => lspserver.isCodeActionProvider,
- 'codeLens': (lspserver) => lspserver.isCodeLensProvider,
- 'selectionRange': (lspserver) => lspserver.isSelectionRangeProvider,
- 'foldingRange': (lspserver) => lspserver.isFoldingRangeProvider,
- }
-
if !SupportedCheckFns->has_key(domain)
# If this happns it is a programming error, and should be fixed in the source code
:throw $'Error: ''{domain}'' is not a valid domain'
endif
endfor
- # Return the first LSP server that supports 'domain'
- return possibleLSPs[0]
+ # Return the first LSP server that supports 'domain' and doesn't have it
+ # disabled
+ for lspserver in possibleLSPs
+ if !lspserver.features->has_key(domain)
+ return lspserver
+ endif
+ endfor
+
+ return {}
enddef
# Returns the LSP server for the buffer 'bnr' and with ID 'id'. Returns an empty
*lsp-cfg-features*
features
(Optional) toggle which features should be enabled for a
- given langauge server. See |lsp-multiple-servers| for
- more information.
+ given language server. See |lsp-multiple-servers| and
+ |lsp-features| for more information.
*lsp-cfg-omnicompl*
omnicompl (Optional) a boolean value that enables (true)
or disables (false) omni-completion for this file
By default the language server defined first will be used for as much as it
supports, then the next and so on. With the exception that diagnostics from all
-running language servers will be joined together. This means that you can define
-a language server that only supports a subset of features at first and then
-define the general purpose language server after it: >
+running language servers will be combined.
+This means that you can define a language server that only supports a subset of
+features at first and then define the general purpose language server after it:
+>
vim9script
g:LspAddServer([
}
])
<
-By proving the configuration |lsp-cfg-features| it's possible specify which
-servers should be used for a given method. The following flags are supported: >
-
- #{
- completion: true,
- definition: true,
- declaration: true,
- typeDefinition: true,
- implementation: true,
- hover: true,
- references: true,
- documentHighlight: true,
- documentFormatting: true,
- rename: true,
- codeAction: true,
- codeLens: true,
- selectionRange: true,
- foldingRange: true
- }
-<
-As shown above the order of when the language servers are being defined is taken
-into account for a given method. However sometimes the language server that you
-want to use for formatting also reports that it supports other features, in such
-a case you can change the order of language servers, and specify that a given
-language server should be used for a given method.
+As shown in the example above the order of when the language servers are being
+defined is taken into account for a given method. However sometimes the
+language server that you want to use for formatting also reports that it
+supports other features. In such a case you can do one of two things:
+
+1. change the order of language servers, and specify that a given language
+server should be used for a given method.
+
+2. set the unwanted features to |v:false| in the features |Dictionary| >
+ features: { 'codeAction': v:false }
+<
For example, if you want to use the efm-langserver for formatting, but the
typescript-language-server for everything else: >
}
])
<
+==============================================================================
+17. Language Server Features *lsp-features*
+
+By providing the configuration |lsp-cfg-features| it's possible to specify which
+servers should be used for a given method. The following feature flags are
+supported: See |lsp-multiple-servers| for examples.
+
+ *lsp-features-codeAction*
+codeAction Used by |:LspCodeAction|
+ *lsp-features-codeLens*
+codeLens Used by |:LspCodeLens|
+ *lsp-features-completion*
+completion Used by 24/7 Completion and 'omnifunc'
+ *lsp-features-declaration*
+declaration Used by |:LspGotoDeclaration|, and
+ |:LspPeekDeclaration|
+ *lsp-features-definition*
+definition Used by |:LspGotoDefinition|, and
+ |:LspPeekDefinition|
+ *lsp-features-documentFormatting*
+documentFormatting Used by |:LspFormat|, and 'formatexpr'
+ *lsp-features-documentHighlight*
+documentHighlight Used by |:LspHighlight|, and |:LspHighlightClear|
+ *lsp-features-foldingRange*
+foldingRange Used by |:LspFold|
+ *lsp-features-hover*
+hover Used by |:LspHover|
+ *lsp-features-implementation*
+implementation Used by |:LspGotoImpl|, and |:LspPeekImpl|
+ *lsp-features-references*
+references Used by |:LspShowReferences|
+ *lsp-features-rename*
+rename Used by |:LspRename|
+ *lsp-features-selectionRange*
+selectionRange Used by |:LspSelectionExpand|, and |:LspSelectionShrink|
+ *lsp-features-typeDefinition*
+typeDefinition Used by |:LspGotoTypeDef|, and |:LspPeekTypeDef|
vim:tw=78:ts=8:noet:ft=help:norl: