From fff8f8b6766bd4e30bc737b1352a96a2301c8a45 Mon Sep 17 00:00:00 2001 From: Cosmin Popescu Date: Tue, 1 Nov 2016 20:13:34 +0100 Subject: [PATCH] merging the pull request --- autoload/sw/server.vim | 24 ++++++++++++++++++------ 1 file changed, 18 insertions(+), 6 deletions(-) diff --git a/autoload/sw/server.vim b/autoload/sw/server.vim index 05d9da0..7e3f72b 100644 --- a/autoload/sw/server.vim +++ b/autoload/sw/server.vim @@ -149,13 +149,22 @@ endfunction function! s:start_sqlwb(type) let vid = substitute(v:servername, '\v\/', '-', 'g') . sw#generate_unique_id() let cmd = [g:sw_exe, '-feedback=true', '-showProgress=false', '-showTiming=true', '-nosettings', '-variable=vid=' . vid] + + let valid_exe = 1 + if !filereadable(g:sw_exe) + echom g:sw_exe . " is not readable. Make sure the setting g:sw_exe is set and the file exists." + let valid_exe = 0 + endif + if match(getfperm(g:sw_exe), "r.x.*") ==# -1 + echom g:sw_exe . " is not executable. Make sure the permissions are set correctly." + let valid_exe = 0 + endif + + if !valid_exe + return + endif + if !s:nvim - if !filereadable(g:sw_exe) - echom g:sw_exe . " is not readable. Make sure the setting g:sw_exe is set and the file exists." - endif - if match(getfperm(g:sw_exe), "r.x.*") ==# -1 - echom g:sw_exe . " is not executable. Make sure the permissions are set correctly." - endif let job = job_start(cmd, {'in_mode': 'raw', 'out_mode': 'raw'}) let pid = substitute(job, '\v^process ([0-9]+).*$', '\1', 'g') let pid = '' @@ -250,6 +259,9 @@ function! sw#server#disconnect_buffer(...) if a:0 let channel = a:1 endif + if channel == '' + return + endif if (!s:nvim && ch_status(channel) == 'open') || s:nvim try call sw#server#execute_sql('exit', channel) -- GitLab