1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
|
augroup vimlsp_settings_sqls
au!
LspRegisterServer {
\ 'name': 'sqls',
\ 'cmd': {server_info->lsp_settings#get('sqls', 'cmd', [lsp_settings#exec_path('sqls')])},
\ 'root_uri':{server_info->lsp_settings#get('sqls', 'root_uri', lsp_settings#root_uri('sqls'))},
\ 'initialization_options': lsp_settings#get('sqls', 'initialization_options', v:null),
\ 'whitelist': lsp_settings#get('sqls', 'whitelist', ['sql']),
\ 'blacklist': lsp_settings#get('sqls', 'blacklist', []),
\ 'config': lsp_settings#get('sqls', 'config', lsp_settings#server_config('sqls')),
\ 'workspace_config': lsp_settings#get('sqls', 'workspace_config', {}),
\ 'semantic_highlight': lsp_settings#get('sqls', 'semantic_highlight', {}),
\ }
augroup END
function! s:sqls_query() abort
call lsp#send_request('sqls', {
\ 'method': 'workspace/executeCommand',
\ 'params': {
\ 'command': 'sqls.executeQuery',
\ 'arguments': [lsp#utils#get_buffer_uri()],
\ },
\ 'on_notification': function('s:handle_execute_command'),
\ })
endfunction
function! s:handle_execute_command(data) abort
let l:lines = a:data['response']['result']
vnew
call setline(1, split(l:lines, "\n"))
endfunction
function! s:on_lsp_buffer_enabled() abort
if &ft !=# 'sql'
return
endif
command! -buffer LspSQLQuery call <SID>sqls_query()
endfunction
augroup lsp_install_sqls
au!
autocmd User lsp_buffer_enabled call s:on_lsp_buffer_enabled()
augroup END
|