Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 1 | " Vim filetype plugin file |
Bram Moolenaar | 71b6d33 | 2022-09-10 13:13:14 +0100 | [diff] [blame] | 2 | " Language: sh |
| 3 | " Maintainer: Doug Kearns <dougkearns@gmail.com> |
| 4 | " Previous Maintainer: Dan Sharp |
| 5 | " Last Change: 2022 Sep 07 |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 6 | |
Bram Moolenaar | 71b6d33 | 2022-09-10 13:13:14 +0100 | [diff] [blame] | 7 | if exists("b:did_ftplugin") |
| 8 | finish |
| 9 | endif |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 10 | let b:did_ftplugin = 1 |
| 11 | |
| 12 | " Make sure the continuation lines below do not cause problems in |
| 13 | " compatibility mode. |
| 14 | let s:save_cpo = &cpo |
| 15 | set cpo-=C |
| 16 | |
Bram Moolenaar | 71b6d33 | 2022-09-10 13:13:14 +0100 | [diff] [blame] | 17 | setlocal comments=:# |
| 18 | setlocal commentstring=#\ %s |
| 19 | setlocal formatoptions-=t formatoptions+=croql |
| 20 | |
| 21 | let b:undo_ftplugin = "setl com< cms< fo<" |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 22 | |
| 23 | " Shell: thanks to Johannes Zellner |
Bram Moolenaar | 71b6d33 | 2022-09-10 13:13:14 +0100 | [diff] [blame] | 24 | if 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 Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 33 | endif |
| 34 | |
| 35 | " Change the :browse e filter to primarily show shell-related files. |
Bram Moolenaar | 71b6d33 | 2022-09-10 13:13:14 +0100 | [diff] [blame] | 36 | if (has("gui_win32") || has("gui_gtk")) && !exists("b:browsefilter") |
| 37 | let b:browsefilter = "Bourne Shell Scripts (*.sh)\t*.sh\n" .. |
| 38 | \ "Korn Shell Scripts (*.ksh)\t*.ksh\n" .. |
| 39 | \ "Bash Shell Scripts (*.bash)\t*.bash\n" .. |
| 40 | \ "All Files (*.*)\t*.*\n" |
| 41 | let b:undo_ftplugin ..= " | unlet! b:browsefilter" |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 42 | endif |
| 43 | |
Enno | 2f25e40 | 2023-08-23 21:27:50 +0200 | [diff] [blame] | 44 | if (exists('b:is_bash') && (b:is_bash == 1)) || |
| 45 | \ (exists('b:is_sh') && (b:is_sh == 1)) |
| 46 | if !has('gui_running') && executable('less') |
| 47 | command! -buffer -nargs=1 Help silent exe '!bash -c "{ help "<args>" 2>/dev/null || man "<args>"; } | LESS= less"' | redraw! |
| 48 | elseif has('terminal') |
| 49 | command! -buffer -nargs=1 Help silent exe ':term bash -c "help "<args>" 2>/dev/null || man "<args>""' |
| 50 | else |
| 51 | command! -buffer -nargs=1 Help echo system('bash -c "help <args>" 2>/dev/null || man "<args>"') |
| 52 | endif |
| 53 | setlocal keywordprg=:Help |
| 54 | let b:undo_ftplugin .= '| setlocal keywordprg<' |
| 55 | endif |
| 56 | |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 57 | " Restore the saved compatibility options. |
| 58 | let &cpo = s:save_cpo |
Bram Moolenaar | 84f7235 | 2012-03-11 15:57:40 +0100 | [diff] [blame] | 59 | unlet s:save_cpo |
Bram Moolenaar | 71b6d33 | 2022-09-10 13:13:14 +0100 | [diff] [blame] | 60 | |
| 61 | " vim: nowrap sw=2 sts=2 ts=8 noet: |