1
0
mirror of https://github.com/SpaceVim/SpaceVim.git synced 2025-03-23 17:49:57 +08:00

fix(python): add debug info for Shebang_to_cmd

This commit is contained in:
Eric Wong 2024-06-13 22:35:39 +08:00
parent f818591314
commit 0fccfab12d

View File

@ -282,6 +282,9 @@ endfunction
function! s:Shebang_to_cmd(line) abort function! s:Shebang_to_cmd(line) abort
let executable = matchstr(a:line, '#!\s*\zs[^ ]*') let executable = matchstr(a:line, '#!\s*\zs[^ ]*')
if empty(executable)
return []
endif
let argvs = split(matchstr(a:line, '#!\s*[^ ]\+\s*\zs.*')) let argvs = split(matchstr(a:line, '#!\s*[^ ]\+\s*\zs.*'))
return [executable] + argvs return [executable] + argvs
endfunction endfunction
@ -289,7 +292,14 @@ endfunction
func! s:getexe() abort func! s:getexe() abort
let line = getline(1) let line = getline(1)
if line =~# '^#!' if line =~# '^#!'
return s:Shebang_to_cmd(line) let cmd = s:Shebang_to_cmd(line)
if empty(cmd)
call SpaceVim#logger#debug('failed to parse shebang')
elseif !executable(cmd[0])
call SpaceVim#logger#debug('shebang is not executable')
else
return cmd
endif
endif endif
return [s:python_interpreter] return [s:python_interpreter]
endf endf