Skip to content

Commit 2be2b07

Browse files
Support lsp_document_symbol_detail option (prabirshrestha#1482)
* Support `lsp_document_symbol_detail` option to show details * fixup! Support `lsp_document_symbol_detail` option
1 parent 39bad0b commit 2be2b07

File tree

3 files changed

+21
-2
lines changed

3 files changed

+21
-2
lines changed

autoload/lsp/ui/vim/utils.vim

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ function! lsp#ui#vim#utils#symbols_to_loc_list(server, result) abort
7272
\ 'filename': l:path,
7373
\ 'lnum': l:line,
7474
\ 'col': l:col,
75-
\ 'text': lsp#ui#vim#utils#_get_symbol_text_from_kind(a:server, l:symbol['kind']) . ' : ' . l:symbol['name'],
75+
\ 'text': lsp#ui#vim#utils#_get_symbol_text_from_kind(a:server, l:symbol['kind']) . ' : ' . g:lsp_document_symbol_detail ? l:symbol['detail'] : l:symbol['name'],
7676
\ })
7777
endif
7878
else
@@ -84,7 +84,7 @@ function! lsp#ui#vim#utils#symbols_to_loc_list(server, result) abort
8484
\ 'filename': l:path,
8585
\ 'lnum': l:line,
8686
\ 'col': l:col,
87-
\ 'text': lsp#ui#vim#utils#_get_symbol_text_from_kind(a:server, l:symbol['kind']) . ' : ' . l:symbol['name'],
87+
\ 'text': lsp#ui#vim#utils#_get_symbol_text_from_kind(a:server, l:symbol['kind']) . ' : ' . g:lsp_document_symbol_detail ? l:symbol['detail'] : l:symbol['name'],
8888
\ })
8989
if has_key(l:symbol, 'children') && !empty(l:symbol['children'])
9090
call s:symbols_to_loc_list_children(a:server, l:path, l:list, l:symbol['children'], 1)

doc/vim-lsp.txt

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,7 @@ CONTENTS *vim-lsp-contents*
7474
g:lsp_document_highlight_enabled |g:lsp_document_highlight_enabled|
7575
g:lsp_document_highlight_delay |g:lsp_document_highlight_delay|
7676
g:lsp_get_supported_capabilities |g:lsp_get_supported_capabilities|
77+
g:lsp_document_symbol_detail |g:lsp_document_symbol_detail|
7778
g:lsp_peek_alignment |g:lsp_peek_alignment|
7879
g:lsp_preview_max_width |g:lsp_preview_max_width|
7980
g:lsp_preview_max_height |g:lsp_preview_max_height|
@@ -951,6 +952,22 @@ g:lsp_get_supported_capabilities *g:lsp_get_supported_capabilities*
951952
calling `lsp#default_get_supported_capabilities` from within your
952953
function.
953954

955+
g:lsp_document_symbol_detail *g:lsp_document_symbol_detail*
956+
Type: |Number|
957+
Default: `0`
958+
959+
Determines whether document symbol shows details or not. Set to `1` to
960+
show details.
961+
962+
Note: showing details needs to turn on setting below: >
963+
\ 'capabilities': {
964+
\ 'textDocument': {
965+
\ 'documentSymbol': {
966+
\ 'hierarchicalDocumentSymbolSupport': v:true,
967+
\ },
968+
\ },
969+
\ },
970+
954971
g:lsp_peek_alignment *g:lsp_peek_alignment*
955972
Type: |String|
956973
Default: `"center"`

plugin/lsp.vim

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,8 @@ let g:lsp_code_action_ui = get(g:, 'lsp_code_action_ui', 'preview')
8585

8686
let g:lsp_get_supported_capabilities = get(g:, 'lsp_get_supported_capabilities', [function('lsp#default_get_supported_capabilities')])
8787

88+
let g:lsp_document_symbol_detail = get(g:, 'lsp_document_symbol_detail', 0)
89+
8890
let g:lsp_experimental_workspace_folders = get(g:, 'lsp_experimental_workspace_folders', 0)
8991

9092
if g:lsp_auto_enable

0 commit comments

Comments
 (0)