# filetype to LSP server map
var ftypeServerMap: dict<dict<any>> = {}
+# filetype to omnicompl map
+var omnicomplFtypeMap: dict<bool> = {}
+
# Buffer number to LSP server map
var bufnrToServer: dict<dict<any>> = {}
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)
+enddef
+
+# Reg bool of omnicompl for a filetype.
+def s:lspRegOmnicompl(ftype: string, omnicompl: bool)
+ omnicomplFtypeMap->extend({[ftype]: omnicompl})
+enddef
+
def lsp#enableServerTrace()
ClearTraceLogs()
lsp_server_trace = true
# <Enter> in insert mode stops completion and inserts a <Enter>
inoremap <expr> <buffer> <CR> pumvisible() ? "\<C-Y>\<CR>" : "\<CR>"
else
- setbufvar(bnr, '&omnifunc', 'lsp#omniFunc')
+ if s:lspBoolOmnicompl(ftype)
+ setbufvar(bnr, '&omnifunc', 'lsp#omniFunc')
+ endif
endif
setbufvar(bnr, '&balloonexpr', 'LspDiagExpr()')
ErrMsg('Error: LSP server information is missing filetype or path or args')
continue
endif
+ if !server->has_key('omnicompl')
+ # Default true if didnot reg
+ server['omnicompl'] = v:true
+ endif
if !server.path->filereadable()
ErrMsg('Error: LSP server ' .. server.path .. ' is not found')
return
endif
if server.args->type() != v:t_list
- ErrMsg('Error: Arguments for LSP server ' .. server.path .. ' is not a List')
+ ErrMsg('Error: Arguments for LSP server ' .. server.args .. ' is not a List')
+ return
+ endif
+ if server.omnicompl->type() != v:t_bool
+ ErrMsg('Error: Setting of omnicompl ' .. server.omnicompl .. ' is not a Bool')
return
endif
if server.filetype->type() == v:t_string
s:lspAddServer(server.filetype, lspserver)
+ s:lspRegOmnicompl(server.filetype, server.omnicompl)
elseif server.filetype->type() == v:t_list
for ftype in server.filetype
- s:lspAddServer(ftype, lspserver)
+ s:lspAddServer(ftype, lspserver)
+ s:lspRegOmnicompl(server.filetype, server.omnicompl)
endfor
else
ErrMsg('Error: Unsupported file type information "' ..
\ 'filetype': ['javascript', 'typescript'],
\ 'path': '/usr/local/bin/typescript-language-server',
\ 'args': ['--stdio']
- \ }
+ \ },
\ {
\ 'filetype': 'python',
\ 'path': '/usr/local/bin/pyls',
To disable the auto-compeltion, you can set the LSP_24x7_Complete variable
to v:false in your .vimrc file: >
- let g:LSP_24x7_Complete=v:false
+ let g:LSP_24x7_Complete = v:false
<
If this variable is set, then the LSP plugin doesn't automatically start
completion in insert mode and instead supports omni-completion (|compl-omni|).
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: >
+
+ let lspServers = [
+ \ {
+ \ 'filetype': ['javascript', 'typescript'],
+ \ 'omnicompl': v:true,
+ \ 'path': '/usr/local/bin/typescript-language-server',
+ \ 'args': ['--stdio']
+ \ },
+ \ {
+ \ 'filetype': 'python',
+ \ 'omnicompl': v:false,
+ \ 'path': '/usr/local/bin/pyls',
+ \ 'args': ['--check-parent-process', '-v']
+ \ }
+ \ ]
+<
+adding "omnicompl" into configuration to set for specific ft, default is true.
+
==============================================================================
vim:tw=78:ts=8:noet:ft=help:norl: