Skip to content

Commit f67ef09

Browse files
rhysdprabirshrestha
authored andcommitted
Allow 'cmd' configuration without lambda expression (#219)
1 parent b58841b commit f67ef09

File tree

2 files changed

+17
-2
lines changed

2 files changed

+17
-2
lines changed

autoload/lsp.vim

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -285,7 +285,12 @@ function! s:ensure_start(buf, server_name, cb) abort
285285
return
286286
endif
287287

288-
let l:cmd = l:server_info['cmd'](l:server_info)
288+
let l:cmd_type = type(l:server_info['cmd'])
289+
if l:cmd_type == v:t_list
290+
let l:cmd = l:server_info['cmd']
291+
else
292+
let l:cmd = l:server_info['cmd'](l:server_info)
293+
endif
289294

290295
if empty(l:cmd)
291296
let l:msg = s:new_rpc_error('ignore server start since cmd is empty', { 'server_name': a:server_name })

doc/vim-lsp.txt

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -181,12 +181,22 @@ The vim |dict| containing information about the server.
181181

182182
* cmd:
183183
required
184-
Function that takes |vim-lsp-server_info| as parameter and returns the
184+
Function or array which represents command line to start the language
185+
server.
186+
187+
When function, it takes |vim-lsp-server_info| as parameter and returns the
185188
language server executable to run along with the appropriate arguments
186189
when the appropriate filetype is loaded. This function will only be
187190
called when the server has not started.
188191
Return empty array to ignore starting the server.
189192

193+
When array, the first element is the language server executable and
194+
the rest are the appropriate arguments. It is useful when the command line
195+
can be determined statically and |vim-lsp-server_info| is not necessary.
196+
197+
Example:
198+
'cmd': ['pyls']
199+
190200
Function can be complex based on custom requirements.
191201
For example:
192202
- Use binary from local node_modules folder instead of a global

0 commit comments

Comments
 (0)