robin/laufey

git clone https://git.robinwobin.dev/robin/laufey

zeertzjqMerge pull request #40931 from zeertzjq/vim-9.2.0839e4137a7324

master
2.7 KiB81 linesraw
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")
14  finish
15endif
16let b:did_ftplugin = 1
17
18let s:save_cpo = &cpo
19set cpo-=C
20
21setlocal comments=b:#
22setlocal commentstring=#\ %s
23setlocal formatoptions-=t formatoptions+=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")
29  let b:match_ignorecase = 0
30  let s:sol = '\%(;\s*\|^\s*\)\@<='  " start of line
31  let 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\>'
35  unlet s:sol
36  let b:match_skip = "synIDattr(synID(line('.'),col('.'),0),'name') =~ 'shSnglCase'" 
37  let 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")
41  let  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"
44  if has("win32")
45    let b:browsefilter ..= "All Files (*.*)\t*\n"
46  else
47    let b:browsefilter ..= "All Files (*)\t*\n"
48  endif
49  let 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
57  if exists(':terminal') == 2
58    command! -buffer -nargs=1 ShKeywordPrg call term_start(['bash', '-c', 'help "$1" 2>/dev/null || man "$1"', '--', <q-args>])
59  else
60    command! -buffer -nargs=1 ShKeywordPrg echo system(['bash', '-c', 'help "$1" 2>/dev/null || MANPAGER= man "$1"', '--', <q-args>])
61  endif
62  setlocal keywordprg=:ShKeywordPrg
63  let b:undo_ftplugin ..= " | setl kp< | sil! delc -buffer ShKeywordPrg"
64endif
65
66if (s:is_sh || s:is_bash || s:is_kornshell) && executable('shellcheck')
67  if !exists('current_compiler')
68    compiler shellcheck
69    let b:undo_ftplugin ..= ' | compiler make'
70  endif
71elseif s:is_bash
72  if !exists('current_compiler')
73    compiler bash
74    let b:undo_ftplugin ..= ' | compiler make'
75  endif
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: