Replace dynamic subshell syntax bit with a setting
This commit is contained in:
parent
a9d1c31201
commit
ff7d915872
@ -1,77 +1,18 @@
|
|||||||
" Vim syntax file
|
" Vim syntax file
|
||||||
" Language: Just Command Runner
|
" Language: Just Command Runner
|
||||||
" Maintainer: Dan Buch
|
" Maintainer: Dan Buch <dan@meatballhat.com>
|
||||||
" Latest Revision: 22 May 2021
|
" Latest Revision: 28 May 2021
|
||||||
|
|
||||||
if exists("b:current_syntax")
|
if exists("b:current_syntax")
|
||||||
finish
|
finish
|
||||||
endif
|
endif
|
||||||
|
|
||||||
let b:shell_name = "sh"
|
let b:shell_syntax = "sh"
|
||||||
let b:load_time_cursor = getpos('.')
|
if exists("g:just_shell_syntax")
|
||||||
let b:debug = $JUST_VIM_DEBUG == 'enabled'
|
let b:shell_syntax = g:just_shell_syntax
|
||||||
|
endif
|
||||||
|
|
||||||
function! s:justGetShellName()
|
exe "syn include @setshellsyntax syntax/" . b:shell_syntax . ".vim"
|
||||||
let lineno = 0
|
|
||||||
|
|
||||||
while lineno < line("$")
|
|
||||||
let lineno += 1
|
|
||||||
let line = getline(lineno)
|
|
||||||
|
|
||||||
let set_shell_match = "^ *set *shell *:"
|
|
||||||
if matchstr(line, set_shell_match) == ""
|
|
||||||
if b:debug
|
|
||||||
echom "line number " . lineno . " does not match '" . set_shell_match . "': '" . line . "'"
|
|
||||||
endif
|
|
||||||
|
|
||||||
continue
|
|
||||||
endif
|
|
||||||
|
|
||||||
if b:debug
|
|
||||||
echom "found matching line number " . lineno . ": " . line
|
|
||||||
endif
|
|
||||||
|
|
||||||
:normal /"<CR>lv/"<CR>h"ay:nohl
|
|
||||||
let shell_name = @a
|
|
||||||
|
|
||||||
if shell_name != ""
|
|
||||||
if b:debug
|
|
||||||
echom "returning shell_name: '" . shell_name . "'"
|
|
||||||
endif
|
|
||||||
|
|
||||||
return shell_name
|
|
||||||
endif
|
|
||||||
endwhile
|
|
||||||
|
|
||||||
return "sh"
|
|
||||||
endfunc
|
|
||||||
|
|
||||||
function! s:justSetShellName(shell_name)
|
|
||||||
try
|
|
||||||
if b:debug
|
|
||||||
echom "using shell name: '" . a:shell_name . "'"
|
|
||||||
endif
|
|
||||||
|
|
||||||
exe "syn include @setshellsyntax syntax/" . a:shell_name . ".vim"
|
|
||||||
|
|
||||||
let b:shell_name = a:shell_name
|
|
||||||
catch
|
|
||||||
if b:debug
|
|
||||||
echom "oh no: " v:exception
|
|
||||||
echom "falling back to sh syntax"
|
|
||||||
endif
|
|
||||||
|
|
||||||
syn include @setshellsyntax syntax/sh.vim
|
|
||||||
finally
|
|
||||||
syn region justSubshell matchgroup=justBacktick start="\v\`" skip="\v\\\`" end="\v\`" contains=@setshellsyntax
|
|
||||||
syn region justSubshell matchgroup=justBacktick start="\v\`\`\`" skip="\v\\\`" end="\v\`\`\`" contains=@setshellsyntax
|
|
||||||
endtry
|
|
||||||
endfunc
|
|
||||||
|
|
||||||
call s:justSetShellName(s:justGetShellName())
|
|
||||||
|
|
||||||
delfunc s:justSetShellName
|
|
||||||
delfunc s:justGetShellName
|
|
||||||
|
|
||||||
syn keyword justKeyword alias export if else set
|
syn keyword justKeyword alias export if else set
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user