From: Yegappan Lakshmanan Date: Tue, 15 Nov 2022 13:54:51 +0000 (-0800) Subject: Modify LspOptionsGet() to return a copy of the plugin options. Update comments and doc X-Git-Url: http://www.git.stargrave.org/?a=commitdiff_plain;h=ff83aad68c2424c9469d1f995320dbe1b39dec60;p=vim-lsp.git Modify LspOptionsGet() to return a copy of the plugin options. Update comments and doc --- diff --git a/autoload/lsp/options.vim b/autoload/lsp/options.vim index f1605f7..e24bda2 100644 --- a/autoload/lsp/options.vim +++ b/autoload/lsp/options.vim @@ -42,16 +42,14 @@ export var lspOptions: dict = { snippetSupport: false } -# set LSP options from user provided options +# set the LSP plugin options from the user provided option values export def OptionsSet(opts: dict) - for key in opts->keys() - lspOptions[key] = opts[key] - endfor + lspOptions->extend(opts) enddef -# get LSP options +# return a copy of the LSP plugin options export def OptionsGet(): dict - return lspOptions + return lspOptions->deepcopy() enddef # vim: tabstop=8 shiftwidth=2 softtabstop=2 diff --git a/doc/lsp.txt b/doc/lsp.txt index b7d6e86..724464e 100644 --- a/doc/lsp.txt +++ b/doc/lsp.txt @@ -278,17 +278,15 @@ usePopupInCodeAction When using the |:LspCodeAction| command to display the By default this is set to false. For example, to disable the automatic placement of signs for the LSP -diagnostic messages, you can add the following line to your .vimrc file: -> +diagnostic messages, you can add the following line to your .vimrc file: > + call LspOptionsSet({'autoHighlightDiags': v:false}) < +The LspOptionsGet() function returns a |Dict| of all the LSP plugin options, +To get a particular option value you can use the following: > -And to get or check one option value via its key you can query like following: -> echo LspOptionsGet()['autoHighlightDiags'] < -Or if no specific key but just LspOptionsGet() then to get all options. - ============================================================================== 5. Commands *lsp-commands* diff --git a/plugin/lsp.vim b/plugin/lsp.vim index 163b529..342e459 100644 --- a/plugin/lsp.vim +++ b/plugin/lsp.vim @@ -10,18 +10,22 @@ vim9script import autoload '../autoload/lsp/options.vim' import autoload '../autoload/lsp/lsp.vim' +# Set LSP plugin options from 'opts'. def g:LspOptionsSet(opts: dict) options.OptionsSet(opts) enddef +# Return a copy of all the LSP plugin options def g:LspOptionsGet(): dict return options.OptionsGet() enddef +# Add one or more LSP servers in 'serverList' def g:LspAddServer(serverList: list>) lsp.AddServer(serverList) enddef +# Register 'Handler' callback function for LSP command 'cmd'. def g:LspRegisterCmdHandler(cmd: string, Handler: func) lsp.RegisterCmdHandler(cmd, Handler) enddef