blob: c227838d18f0668f6431edb40a1aa80cb038a519 [file] [log] [blame]
Bram Moolenaar071d4272004-06-13 20:20:40 +00001" Vim filetype plugin file
Bram Moolenaar71b6d332022-09-10 13:13:14 +01002" Language: sh
3" Maintainer: Doug Kearns <dougkearns@gmail.com>
4" Previous Maintainer: Dan Sharp
dkearns2ac708b2023-08-30 06:24:37 +10005" Contributor: Enno Nagel <ennonagel+vim@gmail.com>
6" Last Change: 2023 Aug 29
Bram Moolenaar071d4272004-06-13 20:20:40 +00007
Bram Moolenaar71b6d332022-09-10 13:13:14 +01008if exists("b:did_ftplugin")
9 finish
10endif
Bram Moolenaar071d4272004-06-13 20:20:40 +000011let b:did_ftplugin = 1
12
Bram Moolenaar071d4272004-06-13 20:20:40 +000013let s:save_cpo = &cpo
14set cpo-=C
15
Bram Moolenaar71b6d332022-09-10 13:13:14 +010016setlocal comments=:#
17setlocal commentstring=#\ %s
18setlocal formatoptions-=t formatoptions+=croql
19
20let b:undo_ftplugin = "setl com< cms< fo<"
Bram Moolenaar071d4272004-06-13 20:20:40 +000021
22" Shell: thanks to Johannes Zellner
Bram Moolenaar71b6d332022-09-10 13:13:14 +010023if exists("loaded_matchit") && !exists("b:match_words")
24 let b:match_ignorecase = 0
25 let s:sol = '\%(;\s*\|^\s*\)\@<=' " start of line
26 let b:match_words =
27 \ s:sol .. 'if\>:' .. s:sol.'elif\>:' .. s:sol.'else\>:' .. s:sol .. 'fi\>,' ..
28 \ s:sol .. '\%(for\|while\)\>:' .. s:sol .. 'done\>,' ..
29 \ s:sol .. 'case\>:' .. s:sol .. 'esac\>'
30 unlet s:sol
31 let b:undo_ftplugin ..= " | unlet! b:match_ignorecase b:match_words"
Bram Moolenaar071d4272004-06-13 20:20:40 +000032endif
33
Bram Moolenaar71b6d332022-09-10 13:13:14 +010034if (has("gui_win32") || has("gui_gtk")) && !exists("b:browsefilter")
dkearns2ac708b2023-08-30 06:24:37 +100035 let b:browsefilter = "Bourne Shell Scripts (*.sh)\t*.sh\n" ..
36 \ "Korn Shell Scripts (*.ksh)\t*.ksh\n" ..
37 \ "Bash Shell Scripts (*.bash)\t*.bash\n" ..
38 \ "All Files (*.*)\t*.*\n"
Bram Moolenaar71b6d332022-09-10 13:13:14 +010039 let b:undo_ftplugin ..= " | unlet! b:browsefilter"
Bram Moolenaar071d4272004-06-13 20:20:40 +000040endif
41
Eisuke Kawashima54e1f562023-09-26 03:40:45 +090042if (exists("b:is_bash") && (b:is_bash == 1))
dkearns2ac708b2023-08-30 06:24:37 +100043 if !has("gui_running") && executable("less")
Enno2f25e402023-08-23 21:27:50 +020044 command! -buffer -nargs=1 Help silent exe '!bash -c "{ help "<args>" 2>/dev/null || man "<args>"; } | LESS= less"' | redraw!
45 elseif has('terminal')
46 command! -buffer -nargs=1 Help silent exe ':term bash -c "help "<args>" 2>/dev/null || man "<args>""'
47 else
48 command! -buffer -nargs=1 Help echo system('bash -c "help <args>" 2>/dev/null || man "<args>"')
49 endif
50 setlocal keywordprg=:Help
dkearns2ac708b2023-08-30 06:24:37 +100051 let b:undo_ftplugin ..= " | setl kp< | sil! delc -buffer Help"
Enno2f25e402023-08-23 21:27:50 +020052endif
53
Bram Moolenaar071d4272004-06-13 20:20:40 +000054let &cpo = s:save_cpo
Bram Moolenaar84f72352012-03-11 15:57:40 +010055unlet s:save_cpo
Bram Moolenaar71b6d332022-09-10 13:13:14 +010056
57" vim: nowrap sw=2 sts=2 ts=8 noet: