All patches and comments are welcome. Please squash your changes to logical
commits before using git-format-patch and git-send-email to
patches@git.madduck.net.
If you'd read over the Git project's submission guidelines and adhered to them,
I'd be especially grateful.
4 " @param {name} = string
5 " @param {callback} = funcref
7 function! lsp#ui#vim#execute_command#_register(command_name, callback) abort
8 if has_key(s:commands, a:command_name)
9 throw printf('lsp#ui#vim#execute_command#_register_command: %s already registered.', a:command_name)
12 let s:commands[a:command_name] = a:callback
16 " TODO: This method does not handle any return value.
18 function! lsp#ui#vim#execute_command#_execute(params) abort
19 let l:command_name = a:params['command_name']
20 let l:command_args = get(a:params, 'command_args', v:null)
21 let l:server_name = get(a:params, 'server_name', '')
22 let l:bufnr = get(a:params, 'bufnr', -1)
23 let l:sync = get(a:params, 'sync', v:false)
26 let l:command = { 'command': l:command_name }
27 if l:command_args isnot v:null
28 let l:command['arguments'] = l:command_args
31 " execute command on local.
32 if has_key(s:commands, l:command_name)
34 call s:commands[l:command_name]({
36 \ 'server_name': l:server_name,
37 \ 'command': l:command,
40 call lsp#utils#error(printf('Execute command failed: %s', string(a:params)))
45 " execute command on server.
46 if !empty(l:server_name)
47 call lsp#send_request(l:server_name, {
48 \ 'method': 'workspace/executeCommand',
49 \ 'params': l:command,
51 \ 'on_notification': function('s:handle_execute_command', [l:server_name, l:command]),
57 " handle workspace/executeCommand response
59 function! s:handle_execute_command(server_name, command, data) abort
60 if lsp#client#is_error(a:data['response'])
61 call lsp#utils#error('Execute command failed on ' . a:server_name . ': ' . string(a:command) . ' -> ' . string(a:data))