From 4df2ecb948ce3d1af902fcb34fddf4641a9fdee4 Mon Sep 17 00:00:00 2001 From: Yegappan Lakshmanan Date: Sun, 25 Jun 2023 14:03:51 -0700 Subject: [PATCH] When using multiple language servers, check for the server capabilities in more places --- autoload/lsp/buffer.vim | 6 +++++ autoload/lsp/inlayhints.vim | 2 +- autoload/lsp/lsp.vim | 14 +++++------ autoload/lsp/lspserver.vim | 4 +-- doc/lsp.txt | 49 +++++++++++++++++++++++++------------ 5 files changed, 49 insertions(+), 26 deletions(-) diff --git a/autoload/lsp/buffer.vim b/autoload/lsp/buffer.vim index 2d39a19..4c22547 100644 --- a/autoload/lsp/buffer.vim +++ b/autoload/lsp/buffer.vim @@ -31,6 +31,7 @@ export def BufLspServerRemove(bnr: number, lspserver: dict) enddef var SupportedCheckFns = { + callHierarchy: (lspserver) => lspserver.isCallHierarchyProvider, codeAction: (lspserver) => lspserver.isCodeActionProvider, codeLens: (lspserver) => lspserver.isCodeLensProvider, completion: (lspserver) => lspserver.isCompletionProvider, @@ -38,13 +39,18 @@ var SupportedCheckFns = { definition: (lspserver) => lspserver.isDefinitionProvider, documentFormatting: (lspserver) => lspserver.isDocumentFormattingProvider, documentHighlight: (lspserver) => lspserver.isDocumentHighlightProvider, + documentSymbol: (lspserver) => lspserver.isDocumentSymbolProvider, foldingRange: (lspserver) => lspserver.isFoldingRangeProvider, hover: (lspserver) => lspserver.isHoverProvider, implementation: (lspserver) => lspserver.isImplementationProvider, + inlayHint: (lspserver) => lspserver.isInlayHintProvider, references: (lspserver) => lspserver.isReferencesProvider, rename: (lspserver) => lspserver.isRenameProvider, selectionRange: (lspserver) => lspserver.isSelectionRangeProvider, + signatureHelp: (lspserver) => lspserver.isSignatureHelpProvider, typeDefinition: (lspserver) => lspserver.isTypeDefinitionProvider, + typeHierarchy: (lspserver) => lspserver.isTypeHierarchyProvider, + workspaceSymbol: (lspserver) => lspserver.isWorkspaceSymbolProvider } # Returns the LSP server for the buffer "bnr". If "feature" is specified, diff --git a/autoload/lsp/inlayhints.vim b/autoload/lsp/inlayhints.vim index 87cd8c6..a44e3fc 100644 --- a/autoload/lsp/inlayhints.vim +++ b/autoload/lsp/inlayhints.vim @@ -80,7 +80,7 @@ def LspInlayHintsUpdate() b:LspInlayHintsTimer = -1 endif - var lspserver: dict = buf.CurbufGetServerChecked() + var lspserver: dict = buf.CurbufGetServerChecked('inlayHint') if lspserver->empty() return endif diff --git a/autoload/lsp/lsp.vim b/autoload/lsp/lsp.vim index 7ca4a54..4113104 100644 --- a/autoload/lsp/lsp.vim +++ b/autoload/lsp/lsp.vim @@ -324,7 +324,7 @@ enddef # Show the signature using "textDocument/signatureHelp" LSP method # Invoked from an insert-mode mapping, so return an empty string. def g:LspShowSignature(): string - var lspserver: dict = buf.CurbufGetServerChecked() + var lspserver: dict = buf.CurbufGetServerChecked('signatureHelp') if lspserver->empty() return '' endif @@ -843,7 +843,7 @@ def g:LspRequestDocSymbols() return endif - var lspserver: dict = buf.CurbufGetServer() + var lspserver: dict = buf.CurbufGetServer('documentSymbol') if lspserver->empty() || !lspserver.running || !lspserver.ready return endif @@ -864,7 +864,7 @@ export def ShowDocSymbols() return endif - var lspserver: dict = buf.CurbufGetServer() + var lspserver: dict = buf.CurbufGetServer('documentSymbol') if lspserver->empty() || !lspserver.running || !lspserver.ready return endif @@ -898,7 +898,7 @@ enddef # Display all the locations where the current symbol is called from. # Uses LSP "callHierarchy/incomingCalls" request export def IncomingCalls() - var lspserver: dict = buf.CurbufGetServerChecked() + var lspserver: dict = buf.CurbufGetServerChecked('callHierarchy') if lspserver->empty() return endif @@ -909,7 +909,7 @@ enddef # Display all the symbols used by the current symbol. # Uses LSP "callHierarchy/outgoingCalls" request export def OutgoingCalls() - var lspserver: dict = buf.CurbufGetServerChecked() + var lspserver: dict = buf.CurbufGetServerChecked('callHierarchy') if lspserver->empty() return endif @@ -920,7 +920,7 @@ enddef # Display the type hierarchy for the current symbol. Direction is 0 for # sub types and 1 for super types. export def TypeHierarchy(direction: number) - var lspserver: dict = buf.CurbufGetServerChecked() + var lspserver: dict = buf.CurbufGetServerChecked('typeHierarchy') if lspserver->empty() return endif @@ -977,7 +977,7 @@ enddef # Perform a workspace wide symbol lookup # Uses LSP "workspace/symbol" request export def SymbolSearch(queryArg: string, cmdmods: string) - var lspserver: dict = buf.CurbufGetServerChecked() + var lspserver: dict = buf.CurbufGetServerChecked('workspaceSymbol') if lspserver->empty() return endif diff --git a/autoload/lsp/lspserver.vim b/autoload/lsp/lspserver.vim index 5833de8..1dc4a36 100644 --- a/autoload/lsp/lspserver.vim +++ b/autoload/lsp/lspserver.vim @@ -1233,7 +1233,7 @@ enddef # Support the clangd version of type hierarchy retrieval method. # The method described in the LSP 3.17.0 standard is not supported as clangd # doesn't support that method. -def TypeHiearchy(lspserver: dict, direction: number) +def TypeHierarchy(lspserver: dict, direction: number) # Check whether LSP server supports type hierarchy if !lspserver.isTypeHierarchyProvider util.ErrMsg('LSP server does not support type hierarchy') @@ -1849,7 +1849,7 @@ export def NewLspServer(serverParams: dict): dict outgoingCalls: function(OutgoingCalls, [lspserver]), getOutgoingCalls: function(GetOutgoingCalls, [lspserver]), inlayHintsShow: function(InlayHintsShow, [lspserver]), - typeHierarchy: function(TypeHiearchy, [lspserver]), + typeHierarchy: function(TypeHierarchy, [lspserver]), renameSymbol: function(RenameSymbol, [lspserver]), codeAction: function(CodeAction, [lspserver]), codeLens: function(CodeLens, [lspserver]), diff --git a/doc/lsp.txt b/doc/lsp.txt index e288e20..944204e 100644 --- a/doc/lsp.txt +++ b/doc/lsp.txt @@ -3,7 +3,7 @@ Author: Yegappan Lakshmanan (yegappan AT yahoo DOT com) For Vim version 9.0 and above -Last change: June 18, 2023 +Last change: June 25, 2023 ============================================================================== CONTENTS *lsp-contents* @@ -1639,22 +1639,26 @@ 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. +When using multiple language servers for a given file type, by providing the +configuration |lsp-cfg-features| it is possible to specify which language +server should be used for a given method/functionality. The following feature +flags are supported: See |lsp-multiple-servers| for examples. + *lsp-features-callHierarchy* +callHierarchy Used by the|:LspIncomingCalls| and the + |:LspOutgoingCalls| commands. *lsp-features-codeAction* -codeAction Used by |:LspCodeAction| +codeAction Used by the |:LspCodeAction| command. *lsp-features-codeLens* -codeLens Used by |:LspCodeLens| +codeLens Used by the |:LspCodeLens| command. *lsp-features-completion* completion Used by 24/7 Completion and 'omnifunc' *lsp-features-declaration* -declaration Used by |:LspGotoDeclaration|, and - |:LspPeekDeclaration| +declaration Used by the |:LspGotoDeclaration|, and + the |:LspPeekDeclaration| commands. *lsp-features-definition* -definition Used by |:LspGotoDefinition|, and - |:LspPeekDefinition| +definition Used by the|:LspGotoDefinition|, and + the |:LspPeekDefinition| commands. *lsp-features-diagnostics* diagnostics Used to disable diagnostics for a single language server, by default diagnostics are @@ -1662,26 +1666,39 @@ diagnostics Used to disable diagnostics for a single this to |false| you can ignore diagnostics from a specific server. *lsp-features-documentFormatting* -documentFormatting Used by |:LspFormat|, and 'formatexpr' +documentFormatting Used by the |:LspFormat| command, and + 'formatexpr' *lsp-features-documentHighlight* documentHighlight Used by the |:LspHighlight| and the |:LspHighlightClear| commands. + *lsp-features-documentSymbol* +documentSymbol Used by the |:LspDocumentSymbol| and the + |:LspOutline| commands. *lsp-features-foldingRange* -foldingRange Used by |:LspFold| +foldingRange Used by the|:LspFold| command. *lsp-features-hover* -hover Used by |:LspHover| +hover Used by the |:LspHover| command. *lsp-features-implementation* -implementation Used by |:LspGotoImpl|, and |:LspPeekImpl| +implementation Used by the |:LspGotoImpl| and the + |:LspPeekImpl| commands. + *lsp-features-inlayHint* +inlayHint Used to show the inlay hints for + function/method arguments. *lsp-features-references* -references Used by |:LspShowReferences| +references Used by the |:LspShowReferences| command. *lsp-features-rename* -rename Used by |:LspRename| +rename Used by the |:LspRename| command. *lsp-features-selectionRange* selectionRange Used by the |:LspSelectionExpand| and the |:LspSelectionShrink| commands. + *lsp-features-signatureHelp* +signatureHelp Used by the |:LspShowSignature| command. *lsp-features-typeDefinition* typeDefinition Used by the |:LspGotoTypeDef| and the |:LspPeekTypeDef| commands. +typeHierarchy Used by the |:LspSubTypeHierarchy| and the + |:LspSuperTypeHiearchy| commands. +workspaceSymbol Used by the |:LspSymbolSearch| command. ============================================================================== *lsp-license* -- 2.48.1