Skip to content

Commit 2103352

Browse files
committed
Shutdown the hdevtools background server on Vim exit when appropriate
Fixes #4 <#4>
1 parent 9cfbff0 commit 2103352

File tree

2 files changed

+26
-0
lines changed

2 files changed

+26
-0
lines changed

autoload/hdevtools.vim

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,29 @@
11
let s:hdevtools_info_buffer = -1
22

3+
function! s:shutdown()
4+
let l:cmd = hdevtools#build_command('admin', '--stop-server')
5+
" Must save the output in order for the command to actually run:
6+
let l:dummy = system(l:cmd)
7+
endfunction
8+
9+
function! hdevtools#prepare_shutdown()
10+
let l:cmd = hdevtools#build_command('admin', '--status')
11+
" Must save the output in order for the command to actually run:
12+
let l:dummy = system(l:cmd)
13+
14+
" Only shutdown the hdevtools server on Vim quit if the above 'status'
15+
" command indicated that the hdevtools server isn't currently running: This
16+
" plugin will start the server, so this plugin should be responsible for
17+
" shutting it down when Vim exits.
18+
"
19+
" If on the other hand, the hdevtools server is already running, then we
20+
" shouldn't shut it down on Vim exit, since someone else started it, so it's
21+
" their problem.
22+
if v:shell_error != 0
23+
autocmd VimLeave * call s:shutdown()
24+
endif
25+
endfunction
26+
327
function! hdevtools#info(identifier)
428
let l:identifier = a:identifier
529

ftplugin/haskell/hdevtools.vim

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@ if !s:has_hdevtools
1818
finish
1919
endif
2020

21+
call hdevtools#prepare_shutdown()
22+
2123
if exists('b:undo_ftplugin')
2224
let b:undo_ftplugin .= ' | '
2325
else

0 commit comments

Comments
 (0)