All patches and comments are welcome. Please squash your changes to logical
commits before using git-format-patch and git-send-email to
patches@git.madduck.net.
If you'd read over the Git project's submission guidelines and adhered to them,
I'd be especially grateful.
1 " https://microsoft.github.io/language-server-protocol/specification#textDocument_documentSymbol
3 " bufnr: bufnr('%') " optional
4 " server - 'server_name' " optional
6 function! lsp#internal#document_symbol#search#do(options) abort
7 let l:bufnr = get(a:options, 'bufnr', bufnr('%'))
8 if has_key(a:options, 'server')
9 let l:servers = [a:options['server']]
11 let l:servers = filter(lsp#get_allowed_servers(), 'lsp#capabilities#has_document_symbol_provider(v:val)')
14 if len(l:servers) == 0
15 let l:filetype = getbufvar(l:bufnr, '&filetype')
16 call lsp#utils#error('textDocument/documentSymbol not supported for ' . l:filetype)
20 redraw | echo 'Retrieving document symbols ...'
22 call lsp#internal#ui#quickpick#open({
27 \ 'on_accept': function('s:on_accept'),
28 \ 'on_close': function('s:on_close'),
31 let s:Dispose = lsp#callbag#pipe(
32 \ lsp#callbag#fromList(l:servers),
33 \ lsp#callbag#flatMap({server->
35 \ lsp#request(server, {
36 \ 'method': 'textDocument/documentSymbol',
38 \ 'textDocument': lsp#get_text_document_identifier(l:bufnr),
41 \ lsp#callbag#map({x->{'server': server, 'request': x['request'], 'response': x['response']}}),
44 \ lsp#callbag#scan({acc, curr->add(acc, curr)}, []),
45 \ lsp#callbag#tap({x->s:update_ui_items(x)}),
46 \ lsp#callbag#subscribe({
47 \ 'complete':{->lsp#internal#ui#quickpick#busy(0)},
48 \ 'error':{e->s:on_error(e)},
53 function! s:update_ui_items(x) abort
56 let l:items += lsp#ui#vim#utils#symbols_to_loc_list(l:i['server'], l:i)
58 call lsp#internal#ui#quickpick#items(l:items)
61 function! s:on_accept(data, ...) abort
62 call lsp#internal#ui#quickpick#close()
63 call lsp#utils#location#_open_vim_list_item(a:data['items'][0], '')
66 function! s:on_close(...) abort
67 if exists('s:Dispose')
73 function! s:on_error(e) abort
74 call lsp#internal#ui#quickpick#close()
75 call lsp#log('LspDocumentSymbolSearch error', a:e)