]> Sergey Matveev's repositories - vim-lsp.git/commitdiff
feat: add LspServerStatus(ft) func to detect ft lsp server was running or not
authorshane.xb.qian <shane.qian@foxmail.com>
Wed, 26 Oct 2022 11:34:41 +0000 (19:34 +0800)
committershane.xb.qian <shane.qian@foxmail.com>
Wed, 26 Oct 2022 11:34:41 +0000 (19:34 +0800)
autoload/lsp/lsp.vim
plugin/lsp.vim

index e911e2131234ff8b60a15fb822c800ef68638492..9442717a04679dfdc14bfbd3c99ebfc1f7f3f268 100644 (file)
@@ -97,19 +97,6 @@ export def EnableServerTrace()
   util.ServerTrace(true)
 enddef
 
-# Get LSP server status for filetype 'ftype'.
-# Return true if running, otherwise false if not found or not running.
-# But lsp init for cur 'buf' maybe not done yet even this func return true,
-# check 'g:LspServerReady()' for that instead.
-def g:LspServerStatus(ftype: string): bool
-  for [ft, lspserver] in ftypeServerMap->items()
-    if ftype ==# ft
-      return lspserver.running
-    endif
-  endfor
-  return v:false
-enddef
-
 # Show information about all the LSP servers
 export def ShowServers()
   for [ftype, lspserver] in ftypeServerMap->items()
@@ -124,6 +111,17 @@ export def ShowServers()
   endfor
 enddef
 
+# Get LSP server status for filetype 'ftype'
+# Return true if running, or false if not found or not running
+export def ServerStatus(ftype: string): bool
+  for [ft, lspserver] in ftypeServerMap->items()
+    if ftype ==# ft
+      return lspserver.running
+    endif
+  endfor
+  return v:false
+enddef
+
 # Go to a definition using "textDocument/definition" LSP request
 export def GotoDefinition(peek: bool)
   var lspserver: dict<any> = CurbufGetServerChecked()
index f0df9da9fb910cc7dc033e6415caea656a693d6d..64da174a76c5dd719d6baa0cfa1b6d92d54c48ae 100644 (file)
@@ -26,6 +26,10 @@ def g:LspServerReady(): bool
   return lsp.ServerReady()
 enddef
 
+def g:LspServerStatus(ftype: string): bool
+  return lsp.ServerStatus(ftype)
+enddef
+
 # Command line completion function for the LspSetTrace command.
 def LspServerTraceComplete(arglead: string, cmdline: string, cursorpos: number): list<string>
   var l = ['off', 'messages', 'verbose']