Skip to content

Commit 4a0fe58

Browse files
committed
add window/showDocument support
1 parent 7dd6b72 commit 4a0fe58

File tree

3 files changed

+22
-0
lines changed

3 files changed

+22
-0
lines changed

autoload/lsp.vim

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -630,6 +630,9 @@ function! lsp#default_get_supported_capabilities(server_info) abort
630630
\ },
631631
\ 'window': {
632632
\ 'workDoneProgress': g:lsp_work_done_progress_enabled ? v:true : v:false,
633+
\ 'showDocument': {
634+
\ 'support': g:lsp_experimental_show_document ? v:true : v:false,
635+
\ },
633636
\ },
634637
\ 'workspace': {
635638
\ 'applyEdit': v:true,
@@ -944,6 +947,15 @@ function! s:on_request(server_name, id, request) abort
944947
endif
945948
elseif a:request['method'] ==# 'window/workDoneProgress/create'
946949
call s:send_response(a:server_name, { 'id': a:request['id'], 'result': v:null})
950+
elseif a:request['method'] ==# 'window/showDocument'
951+
if !g:lsp_experimental_show_document | return | endif
952+
let l:cmd = g:lsp_show_document_command
953+
if has_key(a:request['params'], 'selection')
954+
let l:cmd .= " +" . a:request['params']['selection']['start']['line']
955+
endif
956+
let l:cmd .= " " . lsp#utils#uri_to_path(a:request['params']['uri'])
957+
execute l:cmd
958+
call s:send_response(a:server_name, { 'id': a:request['id'], 'result': {'success': v:true}})
947959
else
948960
" TODO: for now comment this out until we figure out a better solution.
949961
" We need to comment this out so that others outside of vim-lsp can

doc/vim-lsp.txt

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2241,6 +2241,14 @@ call `root_uri` function to detect the workspace folder. If the folder is not
22412241
part of workspace folder, it will automatically notify the server to add the
22422242
workspace folder.
22432243

2244+
==============================================================================
2245+
Show Document *vim-lsp-show-document*
2246+
2247+
Show Document is an experimental feature of vim-lsp. To enable this, set
2248+
folders set `let g:lsp_experimental_show_document = 1`.
2249+
2250+
When the client and the server supports Show Document, the client open a file
2251+
requested from the server.
22442252
=============================================================================
22452253
License *vim-lsp-license*
22462254

plugin/lsp.vim

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,8 @@ let g:lsp_get_supported_capabilities = get(g:, 'lsp_get_supported_capabilities',
8888
let g:lsp_document_symbol_detail = get(g:, 'lsp_document_symbol_detail', 0)
8989

9090
let g:lsp_experimental_workspace_folders = get(g:, 'lsp_experimental_workspace_folders', 0)
91+
let g:lsp_experimental_show_document = get(g:, 'lsp_experimental_show_document', 0)
92+
let g:lsp_show_document_command = get(g:, 'lsp_show_document_command', 'edit')
9193

9294
if g:lsp_auto_enable
9395
augroup lsp_auto_enable

0 commit comments

Comments
 (0)