]> Sergey Matveev's repositories - vim-lsp.git/commitdiff
When using multiple language servers, check for the server capabilities in more places
authorYegappan Lakshmanan <yegappan@yahoo.com>
Sun, 25 Jun 2023 21:03:51 +0000 (14:03 -0700)
committerYegappan Lakshmanan <yegappan@yahoo.com>
Sun, 25 Jun 2023 21:03:51 +0000 (14:03 -0700)
autoload/lsp/buffer.vim
autoload/lsp/inlayhints.vim
autoload/lsp/lsp.vim
autoload/lsp/lspserver.vim
doc/lsp.txt

index 2d39a19cd4895acb2d1d6ffe27126a9c6d7e31fe..4c22547b2cdc1ca4fd13296ee17949678229b0e4 100644 (file)
@@ -31,6 +31,7 @@ export def BufLspServerRemove(bnr: number, lspserver: dict<any>)
 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,
index 87cd8c620299d01207c88ba22ca5bb1d34f480da..a44e3fcf5f46be80376a1c04eec87c1210983549 100644 (file)
@@ -80,7 +80,7 @@ def LspInlayHintsUpdate()
     b:LspInlayHintsTimer = -1
   endif
 
-  var lspserver: dict<any> = buf.CurbufGetServerChecked()
+  var lspserver: dict<any> = buf.CurbufGetServerChecked('inlayHint')
   if lspserver->empty()
     return
   endif
index 7ca4a54f7c3dd205b2edd66e8c05d9b8c8e68d12..41131048ac4c49a8ed189e73b379af348d74bf61 100644 (file)
@@ -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<any> = buf.CurbufGetServerChecked()
+  var lspserver: dict<any> = buf.CurbufGetServerChecked('signatureHelp')
   if lspserver->empty()
     return ''
   endif
@@ -843,7 +843,7 @@ def g:LspRequestDocSymbols()
     return
   endif
 
-  var lspserver: dict<any> = buf.CurbufGetServer()
+  var lspserver: dict<any> = buf.CurbufGetServer('documentSymbol')
   if lspserver->empty() || !lspserver.running || !lspserver.ready
     return
   endif
@@ -864,7 +864,7 @@ export def ShowDocSymbols()
     return
   endif
 
-  var lspserver: dict<any> = buf.CurbufGetServer()
+  var lspserver: dict<any> = 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<any> = buf.CurbufGetServerChecked()
+  var lspserver: dict<any> = 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<any> = buf.CurbufGetServerChecked()
+  var lspserver: dict<any> = 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<any> = buf.CurbufGetServerChecked()
+  var lspserver: dict<any> = 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<any> = buf.CurbufGetServerChecked()
+  var lspserver: dict<any> = buf.CurbufGetServerChecked('workspaceSymbol')
   if lspserver->empty()
     return
   endif
index 5833de8b335fbba96ed025cd9b2170ab57c8b48a..1dc4a3637d87375606c181aeac67341a88396a0b 100644 (file)
@@ -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<any>, direction: number)
+def TypeHierarchy(lspserver: dict<any>, 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<any>): dict<any>
     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]),
index e288e2033479678addd0460100e214ccf60a07d9..944204e221042241a04349665c3211df09e0fec4 100644 (file)
@@ -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*