Skip to content

Commit 1d48fc8

Browse files
thomasfaingnaertprabirshrestha
authored andcommitted
Implement workspace/configuration (#427)
1 parent 533aef1 commit 1d48fc8

File tree

2 files changed

+19
-1
lines changed

2 files changed

+19
-1
lines changed

autoload/lsp.vim

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -375,7 +375,8 @@ endfunction
375375
function! lsp#default_get_supported_capabilities(server_info) abort
376376
return {
377377
\ 'workspace': {
378-
\ 'applyEdit': v:true
378+
\ 'applyEdit': v:true,
379+
\ 'configuration': v:true
379380
\ }
380381
\ }
381382
endfunction
@@ -627,6 +628,9 @@ function! s:on_request(server_name, id, request) abort
627628
if a:request['method'] ==# 'workspace/applyEdit'
628629
call lsp#utils#workspace_edit#apply_workspace_edit(a:request['params']['edit'])
629630
call s:send_response(a:server_name, { 'id': a:request['id'], 'result': { 'applied': v:true } })
631+
elseif a:request['method'] ==# 'workspace/configuration'
632+
let l:response_items = map(a:request['params']['items'], { key, val -> lsp#utils#workspace_config#get_value(a:server_name, val) })
633+
call s:send_response(a:server_name, { 'id': a:request['id'], 'result': l:response_items })
630634
else
631635
" Error returned according to json-rpc specification.
632636
call s:send_response(a:server_name, { 'id': a:request['id'], 'error': { 'code': -32601, 'message': 'Method not found' } })
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
function! lsp#utils#workspace_config#get_value(server_name, item) abort
2+
try
3+
let l:server_info = lsp#get_server_info(a:server_name)
4+
let l:config = l:server_info['workspace_config']
5+
6+
for section in split(a:item['section'], '\.')
7+
let l:config = l:config[l:section]
8+
endfor
9+
10+
return l:config
11+
catch
12+
return v:null
13+
endtry
14+
endfunction

0 commit comments

Comments
 (0)