Skip to content

Commit d821bd8

Browse files
authored
Allow LspWorkspaceSymbol query on cmdline (#742)
Allow users to specify their query on the cmdline so they have easier access to registers and vim-editing methods (especially with ctrl-f to enter cmdline-window).
1 parent 36cc104 commit d821bd8

File tree

2 files changed

+9
-5
lines changed

2 files changed

+9
-5
lines changed

autoload/lsp/ui/vim.vim

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -253,7 +253,7 @@ function! lsp#ui#vim#document_range_format_opfunc(type) abort
253253
return s:document_format_range(1, a:type)
254254
endfunction
255255

256-
function! lsp#ui#vim#workspace_symbol() abort
256+
function! lsp#ui#vim#workspace_symbol(query) abort
257257
let l:servers = filter(lsp#get_allowed_servers(), 'lsp#capabilities#has_workspace_symbol_provider(v:val)')
258258
let l:command_id = lsp#_new_command()
259259

@@ -262,9 +262,13 @@ function! lsp#ui#vim#workspace_symbol() abort
262262
return
263263
endif
264264

265-
let l:query = inputdialog('query>', '', "\<ESC>")
266-
if l:query ==# "\<ESC>"
267-
return
265+
if !empty(a:query)
266+
let l:query = a:query
267+
else
268+
let l:query = inputdialog('query>', '', "\<ESC>")
269+
if l:query ==# "\<ESC>"
270+
return
271+
endif
268272
endif
269273

270274
for l:server in l:servers

plugin/lsp.vim

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ command! LspRename call lsp#ui#vim#rename()
9393
command! LspTypeDefinition call lsp#ui#vim#type_definition(0, <q-mods>)
9494
command! LspTypeHierarchy call lsp#internal#type_hierarchy#show()
9595
command! LspPeekTypeDefinition call lsp#ui#vim#type_definition(1)
96-
command! LspWorkspaceSymbol call lsp#ui#vim#workspace_symbol()
96+
command! -nargs=? LspWorkspaceSymbol call lsp#ui#vim#workspace_symbol(<q-args>)
9797
command! -range LspDocumentFormat call lsp#ui#vim#document_format()
9898
command! -range LspDocumentFormatSync call lsp#ui#vim#document_format_sync()
9999
command! -range LspDocumentRangeFormat call lsp#ui#vim#document_range_format()

0 commit comments

Comments
 (0)