]> Sergey Matveev's repositories - vim-lsp.git/commitdiff
Add commands to display information about language server
authorYegappan Lakshmanan <yegappan@yahoo.com>
Mon, 27 Mar 2023 03:07:36 +0000 (20:07 -0700)
committerYegappan Lakshmanan <yegappan@yahoo.com>
Mon, 27 Mar 2023 03:07:36 +0000 (20:07 -0700)
README.md
autoload/lsp/lsp.vim
autoload/lsp/options.vim
doc/lsp.txt
plugin/lsp.vim

index c7d8aaea4eeaf31f8fcdf40d98e9f0c55c16d986..2fea0def652a53b137123a2bacf764ed86a599ba 100644 (file)
--- a/README.md
+++ b/README.md
@@ -147,22 +147,22 @@ The following commands are provided to use the LSP features.
 Command|Description
 -------|-----------
 :LspCodeAction|Apply the code action supplied by the language server to the diagnostic in the current line.
-:LspDiagCurrent|Display the diagnostic message for the current line
-:LspDiagFirst|Jump to the first diagnostic message for the current buffer
-:LspDiagHere|Jump to the next diagnostic message in the current line
-:LspDiagHighlightDisable|Disable diagnostic message highlights
-:LspDiagHighlightEnable|Enable diagnostic message highlights
-:LspDiagNext|Jump to the next diagnostic message after the current position
-:LspDiagPrev|Jump to the previous diagnostic message before the current position
+:LspDiagCurrent|Display the diagnostic message for the current line.
+:LspDiagFirst|Jump to the first diagnostic message for the current buffer.
+:LspDiagHere|Jump to the next diagnostic message in the current line.
+:LspDiagHighlightDisable|Disable diagnostic message highlights.
+:LspDiagHighlightEnable|Enable diagnostic message highlights.
+:LspDiagNext|Jump to the next diagnostic message after the current position.
+:LspDiagPrev|Jump to the previous diagnostic message before the current position.
 :LspDiagShow|Display the diagnostics messages from the language server for the current buffer in a new location list.
-:LspFold|Fold the current file
+:LspFold|Fold the current file.
 :LspFormat|Format a range of lines in the current file using the language server. The **shiftwidth** and **expandtab** values set for the current buffer are used when format is applied.  The default range is the entire file.
-:LspGotoDeclaration|Go to the declaration of the keyword under cursor
-:LspGotoDefinition|Go to the definition of the keyword under cursor
-:LspGotoImpl|Go to the implementation of the keyword under cursor
-:LspGotoTypeDef|Go to the type definition of the keyword under cursor
-:LspHighlight|Highlight all the matches for the keyword under cursor
-:LspHighlightClear|Clear all the matches highlighted by :LspHighlight
+:LspGotoDeclaration|Go to the declaration of the keyword under cursor.
+:LspGotoDefinition|Go to the definition of the keyword under cursor.
+:LspGotoImpl|Go to the implementation of the keyword under cursor.
+:LspGotoTypeDef|Go to the type definition of the keyword under cursor.
+:LspHighlight|Highlight all the matches for the keyword under cursor.
+:LspHighlightClear|Clear all the matches highlighted by :LspHighlight.
 :LspHover|Show the documentation for the symbol under the cursor in a popup window.
 :LspIncomingCalls|Display the list of symbols calling the current symbol.
 :LspOutgoingCalls|Display the list of symbols called by the current symbol.
@@ -172,21 +172,22 @@ Command|Description
 :LspPeekImpl|Open the implementation of the symbol under cursor in the preview window.
 :LspPeekReferences|Display the list of references to the keyword under cursor in a location list associated with the preview window.
 :LspPeekTypeDef|Open the type definition of the symbol under cursor in the preview window.
-:LspRename|Rename the current symbol
-:LspSelectionExpand|Expand the current symbol range visual selection
-:LspSelectionShrink|Shrink the current symbol range visual selection
-:LspServerRestart|Restart the language server for the current buffer
+:LspRename|Rename the current symbol.
+:LspSelectionExpand|Expand the current symbol range visual selection.
+:LspSelectionShrink|Shrink the current symbol range visual selection.
+:LspShowAllServers|Display information about all the registered language servers.
+:LspServerRestart|Restart the language server for the current buffer.
 :LspShowReferences|Display the list of references to the keyword under cursor in a new location list.
-:LspShowServers|Display the list of registered language servers
-:LspShowServerCapabilities|Display the language server capabilities for the current buffer
-:LspShowSignature|Display the signature of the keyword under cursor
-:LspSubTypeHierarchy|Display the sub type hierarchy in a popup window
-:LspSuperTypeHierarchy|Display the super type hierarchy in a popup window
+:LspShowServer|Display the language server status for the current buffer.
+:LspShowServerCapabilities|Display the language server capabilities for the current buffer.
+:LspShowSignature|Display the signature of the keyword under cursor.
+:LspSubTypeHierarchy|Display the sub type hierarchy in a popup window.
+:LspSuperTypeHierarchy|Display the super type hierarchy in a popup window.
 :LspSwitchSourceHeader|Switch between a source and a header file.
-:LspSymbolSearch|Perform a workspace wide search for a symbol
-:LspWorkspaceAddFolder `{folder}`| Add a folder to the workspace
-:LspWorkspaceListFolders|Show the list of folders in the workspace
-:LspWorkspaceRemoveFolder `{folder}`|Remove a folder from the workspace
+:LspSymbolSearch|Perform a workspace wide search for a symbol.
+:LspWorkspaceAddFolder `{folder}`| Add a folder to the workspace.
+:LspWorkspaceListFolders|Show the list of folders in the workspace.
+:LspWorkspaceRemoveFolder `{folder}`|Remove a folder from the workspace.
 
 ## Similar Vim LSP Plugins
 
index 097ba56a69c8406eac00d5574182960c0e7be7e2..c6fc4b23733b4b955bbdedc2658f3efc3f36caad 100644 (file)
@@ -79,17 +79,64 @@ export def ServerDebug(arg: string)
 enddef
 
 # Show information about all the LSP servers
-export def ShowServers()
+export def ShowAllServers()
+  var lines = []
+  # Add filetype to server mapping information
+  lines->add('Filetype Information')
+  lines->add('====================')
   for [ftype, lspserver] in ftypeServerMap->items()
-    var msg = $'{ftype}    '
-    if lspserver.running
-      msg ..= 'running'
-    else
-      msg ..= 'not running'
+    lines->add($"Filetype: '{ftype}'")
+    lines->add($"Server Path: '{lspserver.path}'")
+    lines->add($"Status: {lspserver.running ? 'Running' : 'Not running'}")
+    lines->add('')
+  endfor
+
+  # Add buffer to server mapping information
+  lines->add('Buffer Information')
+  lines->add('==================')
+  for bnr in range(1, bufnr('$'))
+    if buf.BufHasLspServer(bnr)
+      lines->add($"Buffer: '{bufname(bnr)}'")
+      var lspserver = buf.BufLspServerGet(bnr)
+      lines->add($"Server Path: '{lspserver.path}'")
+      lines->add($"Status: {lspserver.running ? 'Running' : 'Not running'}")
+      lines->add('')
     endif
-    msg ..= $'    {lspserver.path}'
-    :echomsg msg
   endfor
+
+  var wid = bufwinid('Language-Servers')
+  if wid != -1
+    wid->win_gotoid()
+    :setlocal modifiable
+    :silent! :%d _
+  else
+    :new Language-Servers
+    :setlocal buftype=nofile
+    :setlocal bufhidden=wipe
+    :setlocal noswapfile
+    :setlocal nonumber nornu
+    :setlocal fdc=0 signcolumn=no
+  endif
+  setline(1, lines)
+  :setlocal nomodified
+  :setlocal nomodifiable
+enddef
+
+# Show the status of the LSP server for the current buffer
+export def ShowServer()
+  var lspserver: dict<any> = buf.CurbufGetServerChecked()
+  if lspserver->empty()
+    :echomsg "LSP Server not found"
+    return
+  endif
+
+  var msg = $"LSP server '{lspserver.path}' is "
+  if lspserver.running
+    msg ..= 'running'
+  else
+    msg ..= 'not running'
+  endif
+  :echomsg msg
 enddef
 
 # Get LSP server running status for filetype 'ftype'
index dea03a88106e30492ab828b082a8bcb2cad0a619..3d3440fca205c3860c9addb64772c99eb0afdadd 100644 (file)
@@ -35,7 +35,7 @@ export var lspOptions: dict<any> = {
   # Make diagnostics show in a popup instead of echoing
   showDiagInPopup: true,
   # Default diagnostic highlight on lines
-  diagLineHL: 'Cursor',
+  diagLineHL: 'DiffAdd',
   # Don't print message when a configured language server is missing.
   ignoreMissingServer: false,
   # Use a floating menu to show the code action menu instead of asking for input
index 65baf36201f97c6bfbdab303b6fe9730e519a895..bb41fd9f4269e5fa202f124a6f6d2d1abc473eca 100644 (file)
@@ -119,12 +119,15 @@ The following commands are provided:
 :LspServerDebug                Enable or disable the language server debug messages.
 :LspServerRestart      Restart the language server for the current buffer.
 :LspServerTrace                Set the language server debug trace value.
+:LspShowAllServers     Display the status of all the registered language
+                       servers.
 :LspShowReferences     Display the list of references to the keyword under
                        cursor in a new location list.
 :LspShowServerCapabilities
                        Display the language server capabilities for the
                        current buffer.
-:LspShowServers                Display the list of registered language servers
+:LspShowServer         Display the status of the language server for the
+                       current buffer.
 :LspShowSignature      Display the signature of the symbol under cursor.
 :LspSubTypeHierarchy   Display the sub type hierarchy in a popup window.
 :LspSuperTypeHierarchy Display the super type hierarchy in a popup window.
@@ -284,8 +287,9 @@ autoHighlightDiags  |Boolean| option. Automatically place signs on the
 autoPopulateDiags      |Boolean| option. Automatically populate the location
                        list with diagnostics from the language server.
                        By default this is set to false.
-diagLineHL             |String| option. Highlight used for diagnostic line.
-                       By default uses "Cursor".  Use "NONE" to disable.
+diagLineHL             |String| option. The highlight group used for a line
+                       with one or more diagnostics.  By default uses
+                       "DiffAdd".  Use "NONE" to disable.
 echoSignature          |Boolean| option.  In insert mode, echo the current
                        symbol signature instead of showing it in a popup.
                        By default this is set to false.
@@ -617,6 +621,16 @@ can map these commands to keys and make it easier to invoke them.
 :LspServerTrace { off | messages | verbose }   *:LspServerTrace*
                        Set the language server debug trace value.
 
+                                               *:LspShowAllServers*
+:LspShowAllServers     Displays the list of registered language servers and
+                       their status.  The language servers are registered
+                       using the LspAddServer() function.  The output is
+                       displayed in a scratch buffer.  The output shows the
+                       Vim file type, the corresponding language server
+                       status and the path to the language server executable.
+                       The language server information for each buffer is
+                       also shown.
+
                                                *:LspShowReferences*
 :LspShowReferences     Creates a new location list with the list of locations
                        where the symbol under the cursor is referenced and
@@ -628,12 +642,10 @@ can map these commands to keys and make it easier to invoke them.
                        described in the LSP protocol specification under the
                        "ServerCapabilities" interface.
 
-                                               *:LspShowServers*
-:LspShowServers                Displays the list of registered language servers and
-                       their status.  The language servers are registered
-                       using the LspAddServer() function. The output shows
-                       the Vim file type, the corresponding language server
-                       status and the path to the language server executable.
+                                               *:LspShowServer*
+:LspShowServer         Displays the language server status for the current
+                       buffer.  The output shows the path to the language
+                       server executable and the server status.
 
                                                *:LspShowSignature*
 :LspShowSignature      Displays the signature of the symbol (e.g. a function
index 51e9f8b25e9e206261fc7955418c55e93c17665f..18b04b4cc54a53eaf9e7694f3415e551a8c4d1c6 100644 (file)
@@ -111,7 +111,8 @@ command! -nargs=0 -bar LspServerRestart lsp.RestartServer()
 command! -nargs=1 -complete=customlist,LspServerTraceComplete -bar LspServerTrace lsp.ServerTraceSet(<q-args>)
 command! -nargs=0 -bar LspShowReferences lsp.ShowReferences(v:false)
 command! -nargs=0 -bar LspShowServerCapabilities lsp.ShowServerCapabilities()
-command! -nargs=0 -bar LspShowServers lsp.ShowServers()
+command! -nargs=0 -bar LspShowServer lsp.ShowServer()
+command! -nargs=0 -bar LspShowAllServers lsp.ShowAllServers()
 command! -nargs=0 -bar LspShowSignature call LspShowSignature()
 # Clangd specifc extension to switch from one C/C++ source file to a
 # corresponding header file