Support hierarchical document symbols#316
Conversation
|
Is there any language server that I can try this without using coc? |
I'm using modified vim-lsc (had to set proper capability) with clangd. |
| endfunction | ||
|
|
||
| function! s:IsDocumentSymbol(sym) | ||
| return has_key(a:sym, 'selectionRange') |
There was a problem hiding this comment.
Why this change? The author of previous patch about this part uses the range.
There was a problem hiding this comment.
Both range and selectionRange are mandatory in documentSymbol response, the latter is used for consistency with CoC behavior.
| " https://microsoft.github.io/language-server-protocol/specification#textDocument_documentSymbol | ||
| function! vista#parser#lsp#ExtractSymbol(symbol, container) abort | ||
| let symbol = a:symbol | ||
| function! vista#parser#lsp#DispatchDocumentSymbols(symbols) |
There was a problem hiding this comment.
This seems to be used only once, therefore it's not worthy to define another function.
autoload/vista/parser/lsp.vim
Outdated
| \ 'kind': a:symbol.kind, | ||
| \ 'level': a:symbol.level | ||
| \ }) | ||
| function! vista#parser#lsp#FilterDocumentSymbols(symbols) abort |
There was a problem hiding this comment.
This function don't have to be public.
There was a problem hiding this comment.
DispatchDocumentSymbols and FilterDocumentSymbols were made public to allow to reuse them in actual CoC handler: the latter contains this exact code.
There was a problem hiding this comment.
hmm, where is the actual coc handler?
There was a problem hiding this comment.
lsp.vim:133: vista#parser#lsp#CocSymbols
There was a problem hiding this comment.
Well, not really: CocSymbols is to be replaced, handler is in executive/coc.vim: s:Extract
autoload/vista/parser/lsp.vim
Outdated
| for lspsym in a:symbols | ||
| let loc = lspsym.location | ||
| if s:IsFileUri(loc.uri) | ||
| call add(a:outlist, s:LspToLocalSymbol(lspsym, loc.range)) | ||
| endif | ||
| endfor |
There was a problem hiding this comment.
Can be simplified as:
| for lspsym in a:symbols | |
| let loc = lspsym.location | |
| if s:IsFileUri(loc.uri) | |
| call add(a:outlist, s:LspToLocalSymbol(lspsym, loc.range)) | |
| endif | |
| endfor | |
| let outlist = map(filter(symbols, 's:IsFileUri(v:val["localtion"]["uri"])'), 's:LspToLocalSymbol(v:val, v:val["location"]["range"])') |
Then no need to define this function.
There was a problem hiding this comment.
The change is ok, but I'd rather leave the function in place to highlight complementary nature of ParseSymboInfoList and ParseDocumentSymbolsRec. Actually both of them use the same functional interface for consistency.
| call filter(symlist, 'index(g:vista_ignore_kinds, v:val) < 0') | ||
| endif | ||
| let g:vista.functions = | ||
| \ filter(copy(symlist), 'v:val.kind ==? "Method" || v:val.kind ==? "Function"') |
There was a problem hiding this comment.
Not sure which one is better, if you put this filter logic into s:GroupSymbolsByKind(), then you have only one for loop, these two fitler can be saved and don't have to worry about the copy.
Needs support from both LSP client and server.
Falls back to grouping symbols by kind when not supported.
Uses CoC data model and renderer.