]> Sergey Matveev's repositories - vim-lsp.git/commitdiff
Add missing lspoptions.vim and add an option for auto highlighting LSP diagnostics
authorYegappan Lakshmanan <yegappan@yahoo.com>
Mon, 15 Nov 2021 02:38:33 +0000 (18:38 -0800)
committerYegappan Lakshmanan <yegappan@yahoo.com>
Mon, 15 Nov 2021 02:38:33 +0000 (18:38 -0800)
autoload/buf.vim
autoload/handlers.vim
autoload/lspoptions.vim [new file with mode: 0644]
doc/lsp.txt

index fb2309ccbbe120cc1a9619d9394312240b008978..92ab8a44ad45bfda943e0ba7510e93455f228b44 100644 (file)
@@ -1,5 +1,7 @@
 vim9script
 
+import lspOptions from './lspoptions.vim'
+
 def s:lspDiagSevToSignName(severity: number): string
   var typeMap: list<string> = ['LspDiagError', 'LspDiagWarning',
                                                'LspDiagInfo', 'LspDiagHint']
@@ -12,6 +14,10 @@ enddef
 # New LSP diagnostic messages received from the server for a file.
 # Update the signs placed in the buffer for this file
 export def LspDiagsUpdated(lspserver: dict<any>, bnr: number)
+  if !lspOptions.autoHighlightDiags
+    return
+  endif
+
   if bnr == -1 || !lspserver.diagsMap->has_key(bnr)
     return
   endif
index 5cf9d12a9688023847c75b4687c8794bfc27a510..0c7834290a7d6dc28226eaa9d7b283c17c31ab6e 100644 (file)
@@ -140,7 +140,7 @@ def s:processSignaturehelpReply(lspserver: dict<any>, req: dict<any>, reply: dic
       startcol = text->stridx(label)
     endif
   endif
-  if lspOptions.showSignature
+  if lspOptions.echoSignature
     echon "\r\r"
     echon ''
     echon strpart(text, 0, startcol)
diff --git a/autoload/lspoptions.vim b/autoload/lspoptions.vim
new file mode 100644 (file)
index 0000000..ab7daa0
--- /dev/null
@@ -0,0 +1,18 @@
+vim9script
+
+# LSP plugin options
+# User can override these by calling the lsp#setOptions() function.
+export var lspOptions: dict<any> = {
+  # In insert mode, complete the current symbol automatically
+  # Otherwise, use omni-completion
+  autoComplete: true,
+  # In normal mode, highlight the current symbol automatically
+  autoHighlight: false,
+  # In insert mode, show the current symbol signature automatically
+  showSignature: true,
+  # In insert mode, echo the current symbol signature in the status line
+  # instead of showing it in a popup
+  echoSignature: false,
+  # Automatically highlight diagnostics messages from LSP server
+  autoHighlightDiags: true
+}
index 5246d998bfad27897e699d13eab7ad718b058920..6e60664c8fa10a7f1216287fbec38ce27501e355 100644 (file)
@@ -2,7 +2,7 @@
 
 Author: Yegappan Lakshmanan  (yegappan AT yahoo DOT com)
 For Vim version 8.2.2342 and above
-Last change: Nov 13, 2021
+Last change: Nov 14, 2021
 
 ==============================================================================
                                                *lsp-license*
@@ -172,6 +172,31 @@ To add a LSP server, the following information is needed:
 The LSP servers are added using the lsp#addServer() function. This function
 accepts a list of LSP servers with the above information.
 
+                                                       *lsp-options*
+Some of the LSP plugin features can be enabled or disabled by using the
+lsp#setOptions() function. This function accepts a dictionary argument with the
+following optional items:
+
+    autoComplete       In insert mode, automatically complete the current
+                       symbol. Otherwise use omni-completion. By default this
+                       is set to true.
+    autoHighlight      In normal mode, automatically highlight all the
+                       occurrences of the symbol under the cursor. By default
+                       this is set to false.
+    showSignature      In insert mode, automatically show the current symbol
+                       signature in a popup. By default this is set to true.
+    echoSignature      In insert mode, echo the current symbol signature
+                       instead of showing it in a popup. By default this is
+                       set to false.
+    autoHighlightDiags Automatically place signs on the lines with a
+                       diagnostic message from the LSP server. By default
+                       this is set to true.
+
+For example, to disable the automatic placement of signs for the LSP
+diagnostic messages, you can add the following line to your .vimrc file:
+
+       call lsp#setOptions({'autoHighlightDiags': v:false})
+
 ==============================================================================
 5. Commands                                            *lsp-commands*