Skip to content

Commit 8a67acf

Browse files
author
Julius Zint
committed
Added OmniSharpFindType command.
This new command behaves exactly like OmniSharpFindSymbol, but only for types. The main motivation was improved performance. The SymbolFilter parameter in the /findsymbols endpoint got added with the merge of pull request #1823. A version of omnisharp-roslyn with this PR included needs to be installed.
1 parent d5bec2f commit 8a67acf

File tree

4 files changed

+16
-5
lines changed

4 files changed

+16
-5
lines changed

autoload/OmniSharp/actions/symbols.vim

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,21 +3,22 @@ set cpoptions&vim
33

44
function! OmniSharp#actions#symbols#Find(...) abort
55
let filter = a:0 && a:1 isnot 0 ? a:1 : ''
6+
let symbolfilter = a:0 == 2 ? a:2 : 'TypeAndMember'
67
if !OmniSharp#IsServerRunning() | return | endif
78
if g:OmniSharp_server_stdio
89
let Callback = function('s:CBFindSymbol', [filter])
9-
call s:StdioFind(filter, Callback)
10+
call s:StdioFind(filter, symbolfilter, Callback)
1011
else
11-
let locs = OmniSharp#py#Eval(printf('findSymbols(%s)', string(filter)))
12+
let locs = OmniSharp#py#Eval(printf('findSymbols(%s, %s)', string(filter), string(symbolfilter)))
1213
if OmniSharp#py#CheckForError() | return | endif
1314
return s:CBFindSymbol(filter, locs)
1415
endif
1516
endfunction
1617

17-
function! s:StdioFind(filter, Callback) abort
18+
function! s:StdioFind(filter, symbolfilter, Callback) abort
1819
let opts = {
1920
\ 'ResponseHandler': function('s:StdioFindRH', [a:Callback]),
20-
\ 'Parameters': { 'Filter': a:filter }
21+
\ 'Parameters': { 'Filter': a:filter, 'SymbolFilter': a:symbolfilter }
2122
\}
2223
call OmniSharp#stdio#Request('/findsymbols', opts)
2324
endfunction

doc/omnisharp-vim.txt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -424,6 +424,12 @@ convenient user re-mapping. These can be used like so: >
424424
:OmniSharpFindSymbol
425425
Fuzzy-search through symbols
426426

427+
*:OmniSharpFindType*
428+
*<Plug>(omnisharp_find_type)*
429+
:OmniSharpFindType
430+
Fuzzy-search through types. Better performance than OmniSharpFindSymbol in
431+
a large codebase.
432+
427433
*:OmniSharpFindUsages*
428434
*<Plug>(omnisharp_find_usages)*
429435
:OmniSharpFindUsages

ftplugin/cs/OmniSharp.vim

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ command! -buffer -bar OmniSharpDocumentation call OmniSharp#actions#documentatio
3131
command! -buffer -bar OmniSharpFindImplementations call OmniSharp#actions#implementations#Find()
3232
command! -buffer -bar OmniSharpFindMembers call OmniSharp#actions#members#Find()
3333
command! -buffer -bar -nargs=? OmniSharpFindSymbol call OmniSharp#actions#symbols#Find(<q-args>)
34+
command! -buffer -bar -nargs=? OmniSharpFindType call OmniSharp#actions#symbols#Find(<q-args>, 'Type')
3435
command! -buffer -bar OmniSharpFindUsages call OmniSharp#actions#usages#Find()
3536
command! -buffer -bar OmniSharpFixUsings call OmniSharp#actions#usings#Fix()
3637
command! -buffer -bar OmniSharpGetCodeActions call OmniSharp#actions#codeactions#Get('normal')
@@ -54,6 +55,7 @@ nnoremap <buffer> <Plug>(omnisharp_documentation) :OmniSharpDocumentation<CR>
5455
nnoremap <buffer> <Plug>(omnisharp_find_implementations) :OmniSharpFindImplementations<CR>
5556
nnoremap <buffer> <Plug>(omnisharp_find_members) :OmniSharpFindMembers<CR>
5657
nnoremap <buffer> <Plug>(omnisharp_find_symbol) :OmniSharpFindSymbol<CR>
58+
nnoremap <buffer> <Plug>(omnisharp_find_type) :OmniSharpFindType<CR>
5759
nnoremap <buffer> <Plug>(omnisharp_find_usages) :OmniSharpFindUsages<CR>
5860
nnoremap <buffer> <Plug>(omnisharp_fix_usings) :OmniSharpFixUsings<CR>
5961
nnoremap <buffer> <Plug>(omnisharp_code_actions) :OmniSharpGetCodeActions<CR>
@@ -97,6 +99,7 @@ let b:undo_ftplugin .= '
9799
\| delcommand OmniSharpFindImplementations
98100
\| delcommand OmniSharpFindMembers
99101
\| delcommand OmniSharpFindSymbol
102+
\| delcommand OmniSharpFindType
100103
\| delcommand OmniSharpFindUsages
101104
\| delcommand OmniSharpFixUsings
102105
\| delcommand OmniSharpGetCodeActions

python/omnisharp/commands.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -215,9 +215,10 @@ def fixUsings():
215215

216216

217217
@vimcmd
218-
def findSymbols(filter=''):
218+
def findSymbols(filter='', symbolfilter=''):
219219
parameters = {}
220220
parameters["filter"] = filter
221+
parameters["symbolfilter"] = symbolfilter
221222
response = getResponse(ctx, '/findsymbols', parameters, json=True)
222223
return quickfixes_from_response(ctx, response['QuickFixes'])
223224

0 commit comments

Comments
 (0)