autoload/buf.vim | 6 ++++++ autoload/handlers.vim | 2 +- autoload/lspoptions.vim | 18 ++++++++++++++++++ doc/lsp.txt | 27 ++++++++++++++++++++++++++- diff --git a/autoload/buf.vim b/autoload/buf.vim index fb2309ccbbe120cc1a9619d9394312240b008978..92ab8a44ad45bfda943e0ba7510e93455f228b44 100644 --- a/autoload/buf.vim +++ b/autoload/buf.vim @@ -1,5 +1,7 @@ vim9script +import lspOptions from './lspoptions.vim' + def s:lspDiagSevToSignName(severity: number): string var typeMap: list = ['LspDiagError', 'LspDiagWarning', 'LspDiagInfo', 'LspDiagHint'] @@ -12,6 +14,10 @@ # 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, bnr: number) + if !lspOptions.autoHighlightDiags + return + endif + if bnr == -1 || !lspserver.diagsMap->has_key(bnr) return endif diff --git a/autoload/handlers.vim b/autoload/handlers.vim index 5cf9d12a9688023847c75b4687c8794bfc27a510..0c7834290a7d6dc28226eaa9d7b283c17c31ab6e 100644 --- a/autoload/handlers.vim +++ b/autoload/handlers.vim @@ -140,7 +140,7 @@ hllen = label->len() 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 index 0000000000000000000000000000000000000000..ab7daa0b0ec8ae263d1892ef671e2ac689a150a6 --- /dev/null +++ b/autoload/lspoptions.vim @@ -0,0 +1,18 @@ +vim9script + +# LSP plugin options +# User can override these by calling the lsp#setOptions() function. +export var lspOptions: dict = { + # 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 +} diff --git a/doc/lsp.txt b/doc/lsp.txt index 5246d998bfad27897e699d13eab7ad718b058920..6e60664c8fa10a7f1216287fbec38ce27501e355 100644 --- a/doc/lsp.txt +++ b/doc/lsp.txt @@ -2,7 +2,7 @@ *lsp.txt* Language Server Protocol (LSP) Plugin for Vim9 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* @@ -171,6 +171,31 @@ (false) omni-completion for this file type. 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*