From: Yegappan Lakshmanan Date: Thu, 25 Feb 2021 04:32:43 +0000 (-0800) Subject: Rename the omni-completion variables for clarity X-Git-Url: http://www.git.stargrave.org/?a=commitdiff_plain;h=901855b34fd1f2f0c60b89b6e3631ef03ff132f5;p=vim-lsp.git Rename the omni-completion variables for clarity --- diff --git a/autoload/lsp.vim b/autoload/lsp.vim index 283c41a..62124ca 100644 --- a/autoload/lsp.vim +++ b/autoload/lsp.vim @@ -21,8 +21,8 @@ var lspServers: list> = [] # filetype to LSP server map var ftypeServerMap: dict> = {} -# filetype to omnicompl map -var omnicomplFtypeMap: dict = {} +# per-filetype omni-completion enabled/disabled table +var ftypeOmniCtrlMap: dict = {} # Buffer number to LSP server map var bufnrToServer: dict> = {} @@ -58,15 +58,15 @@ def s:lspAddServer(ftype: string, lspserver: dict) ftypeServerMap->extend({[ftype]: lspserver}) enddef -# Return bool of omnicompl for a specific filetype. -# Return false if not found. -def s:lspBoolOmnicompl(ftype: string): bool - return omnicomplFtypeMap->get(ftype, v:false) +# Returns true if omni-completion is enabled for filetype 'ftype'. +# Otherwise, returns false. +def s:lspOmniComplEnabled(ftype: string): bool + return ftypeOmniCtrlMap->get(ftype, v:false) enddef -# Reg bool of omnicompl for a filetype. -def s:lspRegOmnicompl(ftype: string, omnicompl: bool) - omnicomplFtypeMap->extend({[ftype]: omnicompl}) +# Enables or disables omni-completion for filetype 'fype' +def s:lspOmniComplSet(ftype: string, enabled: bool) + ftypeOmniCtrlMap->extend({[ftype]: enabled}) enddef def lsp#enableServerTrace() @@ -297,7 +297,7 @@ def lsp#addFile(bnr: number): void # in insert mode stops completion and inserts a inoremap pumvisible() ? "\\" : "\" else - if s:lspBoolOmnicompl(ftype) + if s:lspOmniComplEnabled(ftype) setbufvar(bnr, '&omnifunc', 'lsp#omniFunc') endif endif @@ -357,7 +357,7 @@ def lsp#addServer(serverList: list>) continue endif if !server->has_key('omnicompl') - # Default true if didnot reg + # Enable omni-completion by default server['omnicompl'] = v:true endif @@ -370,7 +370,7 @@ def lsp#addServer(serverList: list>) return endif if server.omnicompl->type() != v:t_bool - ErrMsg('Error: Setting of omnicompl ' .. server.omnicompl .. ' is not a Bool') + ErrMsg('Error: Setting of omnicompl ' .. server.omnicompl .. ' is not a Boolean') return endif @@ -378,11 +378,11 @@ def lsp#addServer(serverList: list>) if server.filetype->type() == v:t_string s:lspAddServer(server.filetype, lspserver) - s:lspRegOmnicompl(server.filetype, server.omnicompl) + s:lspOmniComplSet(server.filetype, server.omnicompl) elseif server.filetype->type() == v:t_list for ftype in server.filetype s:lspAddServer(ftype, lspserver) - s:lspRegOmnicompl(server.filetype, server.omnicompl) + s:lspOmniComplSet(ftype, server.omnicompl) endfor else ErrMsg('Error: Unsupported file type information "' .. diff --git a/doc/lsp.txt b/doc/lsp.txt index 0acef02..121ee95 100644 --- a/doc/lsp.txt +++ b/doc/lsp.txt @@ -2,7 +2,7 @@ Author: Yegappan Lakshmanan (yegappan AT yahoo DOT com) For Vim version 8.2.2342 and above -Last change: Jan 31, 2021 +Last change: Feb 24, 2021 ============================================================================== *lsp-license* @@ -166,6 +166,8 @@ To add a LSP server, the following information is needed: any arguments). args a list of command-line arguments passed to the LSP server. Each argument is a separate List item. + omnicompl a boolean value that enables (true) or disables + (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. @@ -365,15 +367,12 @@ It sets the 'omnifunc' option for the buffers which have a registered LSP server. To complete a symbol in insert mode manually, you can press CTRL-X CTRL-O to invoke completion using the items suggested by the LSP server. -And also indeed e.g: > +You can also enable or disable omni-completion based on a file type by setting +the 'omnicompl' item to 'false' when registering a lsp server for the +filetype. If this item is not specified, then omni-completion is enabled by +default. The following example disables omni-completion for python: > let lspServers = [ - \ { - \ 'filetype': ['javascript', 'typescript'], - \ 'omnicompl': v:true, - \ 'path': '/usr/local/bin/typescript-language-server', - \ 'args': ['--stdio'] - \ }, \ { \ 'filetype': 'python', \ 'omnicompl': v:false, @@ -382,8 +381,6 @@ And also indeed e.g: > \ } \ ] < -adding "omnicompl" into configuration to set for specific ft, default is true. - ============================================================================== vim:tw=78:ts=8:noet:ft=help:norl: