Skip to content

Commit ee29430

Browse files
committed
Allow stopping server by tab-completable sln name
1 parent d74401d commit ee29430

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed

autoload/OmniSharp.vim

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,12 @@ function! OmniSharp#Complete(findstart, base) abort
5757
endfunction
5858

5959

60+
function! OmniSharp#CompleteRunningSln(arglead, cmdline, cursorpos) abort
61+
let jobs = OmniSharp#proc#ListRunningJobs()
62+
return filter(jobs, {_,job -> job =~? a:arglead})
63+
endfunction
64+
65+
6066
function! OmniSharp#IsAnyServerRunning() abort
6167
return !empty(OmniSharp#proc#ListRunningJobs())
6268
endfunction
@@ -208,7 +214,7 @@ endfunction
208214

209215
function! OmniSharp#StopServer(...) abort
210216
let force = a:0 ? a:1 : 0
211-
let sln_or_dir = a:0 > 1 ? a:2 : OmniSharp#FindSolutionOrDir()
217+
let sln_or_dir = a:0 > 1 && len(a:2) > 0 ? a:2 : OmniSharp#FindSolutionOrDir()
212218
if force || OmniSharp#proc#IsJobRunning(sln_or_dir)
213219
if !g:OmniSharp_server_stdio
214220
call OmniSharp#py#Uncache(sln_or_dir)

ftplugin/cs/OmniSharp.vim

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ command! -buffer -bar OmniSharpRestartAllServers call OmniSharp#RestartAllServer
2424
command! -buffer -bar OmniSharpRestartServer call OmniSharp#RestartServer()
2525
command! -buffer -bar -nargs=? -complete=file OmniSharpStartServer call OmniSharp#StartServer(<q-args>)
2626
command! -buffer -bar OmniSharpStopAllServers call OmniSharp#StopAllServers()
27-
command! -buffer -bar OmniSharpStopServer call OmniSharp#StopServer()
27+
command! -buffer -bar -nargs=? -bang -complete=customlist,OmniSharp#CompleteRunningSln OmniSharpStopServer call OmniSharp#StopServer(<bang>0, <q-args>)
2828

2929
command! -buffer -bar OmniSharpCodeFormat call OmniSharp#actions#format#Format()
3030
command! -buffer -bar OmniSharpDocumentation call OmniSharp#actions#documentation#Documentation()

0 commit comments

Comments
 (0)