robin/laufey
git clone https://git.robinwobin.dev/robin/laufey
e4137a7324
master
1" Vim filetype plugin file 2" Language: sh 3" Maintainer: Doug Kearns <dougkearns@gmail.com> 4" Previous Maintainer: Dan Sharp 5" Contributor: Enno Nagel <ennonagel+vim@gmail.com> 6" Eisuke Kawashima 7" Last Change: 2024 Sep 19 by Vim Project (compiler shellcheck) 8" 2024 Dec 29 by Vim Project (improve setting shellcheck compiler) 9" 2025 Mar 09 by Vim Project (set b:match_skip) 10" 2025 Jul 22 by phanium (use :hor term #17822) 11" 2026 Jul 10 by Vim Project (pass K argument as a list, prevent shell injection) 12 13if exists ( "b:did_ftplugin" ) 14finish 15endif 16let b: did_ftplugin = 1 17 18let s: save_cpo = & cpo 19set cpo -= C 20 21setlocal comments = b:# 22setlocal commentstring = #\ %s 23setlocal formatoptions -= tformatoptions += croql 24 25let b: undo_ftplugin = "setl com< cms< fo<" 26 27" Shell: thanks to Johannes Zellner 28if exists ( "loaded_matchit" ) && ! exists ( "b:match_words" ) 29let b: match_ignorecase = 0 30let s: sol = '\%(;\s*\|^\s*\)\@<=' " start of line 31let b: match_words = 32 \s: sol .. 'if\>:' .. s: sol . 'elif\>:' .. s: sol . 'else\>:' .. s: sol .. 'fi\>,' .. 33 \s: sol .. '\%(for\|while\)\>:' .. s: sol .. 'done\>,' .. 34 \s: sol .. 'case\>:' .. s: sol .. 'esac\>' 35unlet s: sol 36let b: match_skip = "synIDattr(synID(line('.'),col('.'),0),'name') =~ 'shSnglCase'" 37let b: undo_ftplugin ..= " | unlet! b:match_ignorecase b:match_words b:match_skip" 38endif 39 40if ( has ( "gui_win32" ) || has ( "gui_gtk" )) && ! exists ( "b:browsefilter" ) 41let b: browsefilter = "Bourne Shell Scripts (*.sh)\t*.sh\n" .. 42 \"Korn Shell Scripts (*.ksh)\t*.ksh\n" .. 43 \"Bash Shell Scripts (*.bash)\t*.bash\n" 44if has ( "win32" ) 45let b: browsefilter ..= "All Files (*.*)\t*\n" 46else 47let b: browsefilter ..= "All Files (*)\t*\n" 48endif 49let b: undo_ftplugin ..= " | unlet! b:browsefilter" 50endif 51 52let s: is_sh = get ( b:, "is_sh" , get ( g:, "is_sh" , 0 )) 53let s: is_bash = get ( b:, "is_bash" , get ( g:, "is_bash" , 0 )) 54let s: is_kornshell = get ( b:, "is_kornshell" , get ( g:, "is_kornshell" , 0 )) 55 56if s: is_bash 57if exists ( ':terminal' ) == 2 58command ! -buffer -nargs = 1 ShKeywordPrg call term_start(['bash', '-c', 'help "$1" 2>/dev/null || man "$1"', '--', <q-args>]) 59else 60command ! -buffer -nargs = 1 ShKeywordPrg echo system(['bash', '-c', 'help "$1" 2>/dev/null || MANPAGER= man "$1"', '--', <q-args>]) 61endif 62setlocal keywordprg = :ShKeywordPrg 63let b: undo_ftplugin ..= " | setl kp< | sil! delc -buffer ShKeywordPrg" 64endif 65 66if ( s: is_sh || s: is_bash || s: is_kornshell ) && executable ( 'shellcheck' ) 67if ! exists ( 'current_compiler' ) 68compiler shellcheck 69let b: undo_ftplugin ..= ' | compiler make' 70endif 71elseif s: is_bash 72if ! exists ( 'current_compiler' ) 73compiler bash 74let b: undo_ftplugin ..= ' | compiler make' 75endif 76endif 77 78let & cpo = s: save_cpo 79unlet s: save_cpo s: is_sh s: is_bash s: is_kornshell 80 81" vim: nowrap sw=2 sts=2 ts=8 noet: