blob: fccfe4be91f1a1354ff80e1601ec07333a50d25c [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>
dkearns2a281cc2023-10-07 04:59:42 +11006" Eisuke Kawashima
Doug Kearns93197fd2024-01-14 20:59:02 +01007" Last Change: 2024 Jan 14
Bram Moolenaar071d4272004-06-13 20:20:40 +00008
Bram Moolenaar71b6d332022-09-10 13:13:14 +01009if exists("b:did_ftplugin")
10 finish
11endif
Bram Moolenaar071d4272004-06-13 20:20:40 +000012let b:did_ftplugin = 1
13
Bram Moolenaar071d4272004-06-13 20:20:40 +000014let s:save_cpo = &cpo
15set cpo-=C
16
Bram Moolenaar71b6d332022-09-10 13:13:14 +010017setlocal comments=:#
18setlocal commentstring=#\ %s
19setlocal formatoptions-=t formatoptions+=croql
20
21let b:undo_ftplugin = "setl com< cms< fo<"
Bram Moolenaar071d4272004-06-13 20:20:40 +000022
23" Shell: thanks to Johannes Zellner
Bram Moolenaar71b6d332022-09-10 13:13:14 +010024if exists("loaded_matchit") && !exists("b:match_words")
25 let b:match_ignorecase = 0
26 let s:sol = '\%(;\s*\|^\s*\)\@<=' " start of line
27 let b:match_words =
28 \ s:sol .. 'if\>:' .. s:sol.'elif\>:' .. s:sol.'else\>:' .. s:sol .. 'fi\>,' ..
29 \ s:sol .. '\%(for\|while\)\>:' .. s:sol .. 'done\>,' ..
30 \ s:sol .. 'case\>:' .. s:sol .. 'esac\>'
31 unlet s:sol
32 let b:undo_ftplugin ..= " | unlet! b:match_ignorecase b:match_words"
Bram Moolenaar071d4272004-06-13 20:20:40 +000033endif
34
Bram Moolenaar71b6d332022-09-10 13:13:14 +010035if (has("gui_win32") || has("gui_gtk")) && !exists("b:browsefilter")
Doug Kearns93197fd2024-01-14 20:59:02 +010036 let b:browsefilter = "Bourne Shell Scripts (*.sh)\t*.sh\n" ..
37 \ "Korn Shell Scripts (*.ksh)\t*.ksh\n" ..
38 \ "Bash Shell Scripts (*.bash)\t*.bash\n"
39 if has("win32")
40 let b:browsefilter ..= "All Files (*.*)\t*\n"
41 else
42 let b:browsefilter ..= "All Files (*)\t*\n"
43 endif
Bram Moolenaar71b6d332022-09-10 13:13:14 +010044 let b:undo_ftplugin ..= " | unlet! b:browsefilter"
Bram Moolenaar071d4272004-06-13 20:20:40 +000045endif
46
dkearns2a281cc2023-10-07 04:59:42 +110047if get(b:, "is_bash", 0)
dkearns2ac708b2023-08-30 06:24:37 +100048 if !has("gui_running") && executable("less")
dkearns2a281cc2023-10-07 04:59:42 +110049 command! -buffer -nargs=1 ShKeywordPrg silent exe '!bash -c "{ help "<args>" 2>/dev/null || man "<args>"; } | LESS= less"' | redraw!
50 elseif has("terminal")
51 command! -buffer -nargs=1 ShKeywordPrg silent exe ':term bash -c "help "<args>" 2>/dev/null || man "<args>""'
Enno2f25e402023-08-23 21:27:50 +020052 else
dkearns2a281cc2023-10-07 04:59:42 +110053 command! -buffer -nargs=1 ShKeywordPrg echo system('bash -c "help <args>" 2>/dev/null || man "<args>"')
Enno2f25e402023-08-23 21:27:50 +020054 endif
dkearns2a281cc2023-10-07 04:59:42 +110055 setlocal keywordprg=:ShKeywordPrg
56 let b:undo_ftplugin ..= " | setl kp< | sil! delc -buffer ShKeywordPrg"
Enno2f25e402023-08-23 21:27:50 +020057endif
58
Bram Moolenaar071d4272004-06-13 20:20:40 +000059let &cpo = s:save_cpo
Bram Moolenaar84f72352012-03-11 15:57:40 +010060unlet s:save_cpo
Bram Moolenaar71b6d332022-09-10 13:13:14 +010061
62" vim: nowrap sw=2 sts=2 ts=8 noet: