Mercurial > vim
annotate runtime/ftplugin/sh.vim @ 32976:d23645a0aca8
runtime: configure keywordpg for some file types (#5566)
Commit: https://github.com/vim/vim/commit/2f25e40b1f545f4aa38377f0c25effb112b5d1ef
Author: Enno <Konfekt@users.noreply.github.com>
Date: Wed Aug 23 21:27:50 2023 +0200
runtime: configure keywordpg for some file types (https://github.com/vim/vim/issues/5566)
Signed-off-by: Christian Brabandt <cb@256bit.org>
author | Christian Brabandt <cb@256bit.org> |
---|---|
date | Thu, 24 Aug 2023 07:33:29 +0200 |
parents | fee9eccee266 |
children | 5c38f02377d5 |
rev | line source |
---|---|
7 | 1 " Vim filetype plugin file |
30202 | 2 " Language: sh |
3 " Maintainer: Doug Kearns <dougkearns@gmail.com> | |
4 " Previous Maintainer: Dan Sharp | |
5 " Last Change: 2022 Sep 07 | |
7 | 6 |
30202 | 7 if exists("b:did_ftplugin") |
8 finish | |
9 endif | |
7 | 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 | |
30202 | 17 setlocal comments=:# |
18 setlocal commentstring=#\ %s | |
19 setlocal formatoptions-=t formatoptions+=croql | |
20 | |
21 let b:undo_ftplugin = "setl com< cms< fo<" | |
7 | 22 |
23 " Shell: thanks to Johannes Zellner | |
30202 | 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" | |
7 | 33 endif |
34 | |
35 " Change the :browse e filter to primarily show shell-related files. | |
30202 | 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" | |
7 | 42 endif |
43 | |
32976
d23645a0aca8
runtime: configure keywordpg for some file types (#5566)
Christian Brabandt <cb@256bit.org>
parents:
30202
diff
changeset
|
44 if (exists('b:is_bash') && (b:is_bash == 1)) || |
d23645a0aca8
runtime: configure keywordpg for some file types (#5566)
Christian Brabandt <cb@256bit.org>
parents:
30202
diff
changeset
|
45 \ (exists('b:is_sh') && (b:is_sh == 1)) |
d23645a0aca8
runtime: configure keywordpg for some file types (#5566)
Christian Brabandt <cb@256bit.org>
parents:
30202
diff
changeset
|
46 if !has('gui_running') && executable('less') |
d23645a0aca8
runtime: configure keywordpg for some file types (#5566)
Christian Brabandt <cb@256bit.org>
parents:
30202
diff
changeset
|
47 command! -buffer -nargs=1 Help silent exe '!bash -c "{ help "<args>" 2>/dev/null || man "<args>"; } | LESS= less"' | redraw! |
d23645a0aca8
runtime: configure keywordpg for some file types (#5566)
Christian Brabandt <cb@256bit.org>
parents:
30202
diff
changeset
|
48 elseif has('terminal') |
d23645a0aca8
runtime: configure keywordpg for some file types (#5566)
Christian Brabandt <cb@256bit.org>
parents:
30202
diff
changeset
|
49 command! -buffer -nargs=1 Help silent exe ':term bash -c "help "<args>" 2>/dev/null || man "<args>""' |
d23645a0aca8
runtime: configure keywordpg for some file types (#5566)
Christian Brabandt <cb@256bit.org>
parents:
30202
diff
changeset
|
50 else |
d23645a0aca8
runtime: configure keywordpg for some file types (#5566)
Christian Brabandt <cb@256bit.org>
parents:
30202
diff
changeset
|
51 command! -buffer -nargs=1 Help echo system('bash -c "help <args>" 2>/dev/null || man "<args>"') |
d23645a0aca8
runtime: configure keywordpg for some file types (#5566)
Christian Brabandt <cb@256bit.org>
parents:
30202
diff
changeset
|
52 endif |
d23645a0aca8
runtime: configure keywordpg for some file types (#5566)
Christian Brabandt <cb@256bit.org>
parents:
30202
diff
changeset
|
53 setlocal keywordprg=:Help |
d23645a0aca8
runtime: configure keywordpg for some file types (#5566)
Christian Brabandt <cb@256bit.org>
parents:
30202
diff
changeset
|
54 let b:undo_ftplugin .= '| setlocal keywordprg<' |
d23645a0aca8
runtime: configure keywordpg for some file types (#5566)
Christian Brabandt <cb@256bit.org>
parents:
30202
diff
changeset
|
55 endif |
d23645a0aca8
runtime: configure keywordpg for some file types (#5566)
Christian Brabandt <cb@256bit.org>
parents:
30202
diff
changeset
|
56 |
7 | 57 " Restore the saved compatibility options. |
58 let &cpo = s:save_cpo | |
3410
94601b379f38
Updated runtime files. Add Dutch translations.
Bram Moolenaar <bram@vim.org>
parents:
2034
diff
changeset
|
59 unlet s:save_cpo |
30202 | 60 |
61 " vim: nowrap sw=2 sts=2 ts=8 noet: |