diff options
author | Alvin Chan <chaucerbao@users.noreply.github.com> | 2019-02-08 11:43:04 -0800 |
---|---|---|
committer | w0rp <w0rp@users.noreply.github.com> | 2019-02-08 19:43:04 +0000 |
commit | 1fb0de2a8e4ff9846a62ec8c6bcbb8aea8856cc7 (patch) | |
tree | 7e41f2f3c06faca244a3c94a322dd8d1ab5afa15 /autoload | |
parent | d21581016ec7008afb00ea8e938505549a1136e9 (diff) | |
download | ale-1fb0de2a8e4ff9846a62ec8c6bcbb8aea8856cc7.zip |
Add `-relative` option to ALESymbolSearch (#2255)
* Add `-relative` option to ALESymbolSearch
* Document the `-relative` option for ALEFindReferences and ALESymbolSearch
Diffstat (limited to 'autoload')
-rw-r--r-- | autoload/ale/symbol.vim | 22 |
1 files changed, 15 insertions, 7 deletions
diff --git a/autoload/ale/symbol.vim b/autoload/ale/symbol.vim index 5180cb86..dba78afa 100644 --- a/autoload/ale/symbol.vim +++ b/autoload/ale/symbol.vim @@ -52,12 +52,12 @@ function! ale#symbol#HandleLSPResponse(conn_id, response) abort if empty(l:item_list) call ale#util#Execute('echom ''No symbols found.''') else - call ale#preview#ShowSelection(l:item_list) + call ale#preview#ShowSelection(l:item_list, l:options) endif endif endfunction -function! s:OnReady(linter, lsp_details, query, ...) abort +function! s:OnReady(linter, lsp_details, query, options, ...) abort let l:buffer = a:lsp_details.buffer " If we already made a request, stop here. @@ -76,34 +76,42 @@ function! s:OnReady(linter, lsp_details, query, ...) abort call setbufvar(l:buffer, 'ale_symbol_request_made', 1) let s:symbol_map[l:request_id] = { \ 'buffer': l:buffer, + \ 'use_relative_paths': has_key(a:options, 'use_relative_paths') ? a:options.use_relative_paths : 0 \} endfunction -function! s:Search(linter, buffer, query) abort +function! s:Search(linter, buffer, query, options) abort let l:lsp_details = ale#lsp_linter#StartLSP(a:buffer, a:linter) if !empty(l:lsp_details) call ale#lsp#WaitForCapability( \ l:lsp_details.connection_id, \ 'symbol_search', - \ function('s:OnReady', [a:linter, l:lsp_details, a:query]), + \ function('s:OnReady', [a:linter, l:lsp_details, a:query, a:options]), \) endif endfunction -function! ale#symbol#Search(query) abort - if type(a:query) isnot v:t_string || empty(a:query) +function! ale#symbol#Search(args) abort + let [l:opts, l:query] = ale#args#Parse(['relative'], a:args) + + if empty(l:query) throw 'A non-empty string must be provided!' endif let l:buffer = bufnr('') + let l:options = {} + + if has_key(l:opts, 'relative') + let l:options.use_relative_paths = 1 + endif " Set a flag so we only make one request. call setbufvar(l:buffer, 'ale_symbol_request_made', 0) for l:linter in ale#linter#Get(getbufvar(l:buffer, '&filetype')) if !empty(l:linter.lsp) && l:linter.lsp isnot# 'tsserver' - call s:Search(l:linter, l:buffer, a:query) + call s:Search(l:linter, l:buffer, l:query, l:options) endif endfor endfunction |