annotate runtime/ftplugin/sh.vim @ 34134:8ae680be2a51

runtime(ftplugin): Use "*" browsefilter pattern to match "All Files" Commit: https://github.com/vim/vim/commit/93197fde0f1db09b1e495cf3eb14a8f42c318b80 Author: Doug Kearns <dougkearns@gmail.com> Date: Sun Jan 14 20:59:02 2024 +0100 runtime(ftplugin): Use "*" browsefilter pattern to match "All Files" Problem: The "*.*" browsefilter pattern only matches all files on Windows (Daryl Lee) Solution: Use "*" to filter on all platforms but keep "*.*" as the label text on Windows. (Fixes #12685, Doug Kearns) The *.* browsefilter pattern used to match "All Files" on Windows is a legacy of the DOS 8.3 filename wildcard matching algorithm. For reasons of backward compatibility this still works on Windows to match all files, even those without an extension. However, this pattern only matches filenames containing a dot on other platforms. This often makes files without an extension difficult to access from the file dialog, e.g., "Makefile" On Windows it is still standard practice to use "*.*" for the filter label so ftplugins should use "All Files (*.*)" on Windows and "All Files (*)" on other platforms. This matches Vim's default browsefilter values. This commit also normalises the browsefilter conditional test to check for the Win32 and GTK GUI features and an unset b:browsefilter. closes: #12759 Signed-off-by: Doug Kearns <dougkearns@gmail.com> Signed-off-by: Christian Brabandt <cb@256bit.org>
author Christian Brabandt <cb@256bit.org>
date Sun, 14 Jan 2024 21:15:03 +0100
parents 665078e8fea1
children 85d7e01f64b7
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1 " Vim filetype plugin file
30202
fee9eccee266 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 28010
diff changeset
2 " Language: sh
fee9eccee266 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 28010
diff changeset
3 " Maintainer: Doug Kearns <dougkearns@gmail.com>
fee9eccee266 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 28010
diff changeset
4 " Previous Maintainer: Dan Sharp
33067
5c38f02377d5 runtime(sh): Update ftplugin (#12950)
Christian Brabandt <cb@256bit.org>
parents: 32976
diff changeset
5 " Contributor: Enno Nagel <ennonagel+vim@gmail.com>
33500
665078e8fea1 runtime(sh): Update ftplugin (#13213)
Christian Brabandt <cb@256bit.org>
parents: 33360
diff changeset
6 " Eisuke Kawashima
34134
8ae680be2a51 runtime(ftplugin): Use "*" browsefilter pattern to match "All Files"
Christian Brabandt <cb@256bit.org>
parents: 33500
diff changeset
7 " Last Change: 2024 Jan 14
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8
30202
fee9eccee266 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 28010
diff changeset
9 if exists("b:did_ftplugin")
fee9eccee266 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 28010
diff changeset
10 finish
fee9eccee266 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 28010
diff changeset
11 endif
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
12 let b:did_ftplugin = 1
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
13
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
14 let s:save_cpo = &cpo
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
15 set cpo-=C
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
16
30202
fee9eccee266 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 28010
diff changeset
17 setlocal comments=:#
fee9eccee266 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 28010
diff changeset
18 setlocal commentstring=#\ %s
fee9eccee266 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 28010
diff changeset
19 setlocal formatoptions-=t formatoptions+=croql
fee9eccee266 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 28010
diff changeset
20
fee9eccee266 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 28010
diff changeset
21 let b:undo_ftplugin = "setl com< cms< fo<"
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
22
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
23 " Shell: thanks to Johannes Zellner
30202
fee9eccee266 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 28010
diff changeset
24 if exists("loaded_matchit") && !exists("b:match_words")
fee9eccee266 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 28010
diff changeset
25 let b:match_ignorecase = 0
fee9eccee266 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 28010
diff changeset
26 let s:sol = '\%(;\s*\|^\s*\)\@<=' " start of line
fee9eccee266 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 28010
diff changeset
27 let b:match_words =
fee9eccee266 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 28010
diff changeset
28 \ s:sol .. 'if\>:' .. s:sol.'elif\>:' .. s:sol.'else\>:' .. s:sol .. 'fi\>,' ..
fee9eccee266 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 28010
diff changeset
29 \ s:sol .. '\%(for\|while\)\>:' .. s:sol .. 'done\>,' ..
fee9eccee266 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 28010
diff changeset
30 \ s:sol .. 'case\>:' .. s:sol .. 'esac\>'
fee9eccee266 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 28010
diff changeset
31 unlet s:sol
fee9eccee266 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 28010
diff changeset
32 let b:undo_ftplugin ..= " | unlet! b:match_ignorecase b:match_words"
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
33 endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
34
30202
fee9eccee266 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 28010
diff changeset
35 if (has("gui_win32") || has("gui_gtk")) && !exists("b:browsefilter")
34134
8ae680be2a51 runtime(ftplugin): Use "*" browsefilter pattern to match "All Files"
Christian Brabandt <cb@256bit.org>
parents: 33500
diff changeset
36 let b:browsefilter = "Bourne Shell Scripts (*.sh)\t*.sh\n" ..
8ae680be2a51 runtime(ftplugin): Use "*" browsefilter pattern to match "All Files"
Christian Brabandt <cb@256bit.org>
parents: 33500
diff changeset
37 \ "Korn Shell Scripts (*.ksh)\t*.ksh\n" ..
8ae680be2a51 runtime(ftplugin): Use "*" browsefilter pattern to match "All Files"
Christian Brabandt <cb@256bit.org>
parents: 33500
diff changeset
38 \ "Bash Shell Scripts (*.bash)\t*.bash\n"
8ae680be2a51 runtime(ftplugin): Use "*" browsefilter pattern to match "All Files"
Christian Brabandt <cb@256bit.org>
parents: 33500
diff changeset
39 if has("win32")
8ae680be2a51 runtime(ftplugin): Use "*" browsefilter pattern to match "All Files"
Christian Brabandt <cb@256bit.org>
parents: 33500
diff changeset
40 let b:browsefilter ..= "All Files (*.*)\t*\n"
8ae680be2a51 runtime(ftplugin): Use "*" browsefilter pattern to match "All Files"
Christian Brabandt <cb@256bit.org>
parents: 33500
diff changeset
41 else
8ae680be2a51 runtime(ftplugin): Use "*" browsefilter pattern to match "All Files"
Christian Brabandt <cb@256bit.org>
parents: 33500
diff changeset
42 let b:browsefilter ..= "All Files (*)\t*\n"
8ae680be2a51 runtime(ftplugin): Use "*" browsefilter pattern to match "All Files"
Christian Brabandt <cb@256bit.org>
parents: 33500
diff changeset
43 endif
30202
fee9eccee266 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 28010
diff changeset
44 let b:undo_ftplugin ..= " | unlet! b:browsefilter"
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
45 endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
46
33500
665078e8fea1 runtime(sh): Update ftplugin (#13213)
Christian Brabandt <cb@256bit.org>
parents: 33360
diff changeset
47 if get(b:, "is_bash", 0)
33067
5c38f02377d5 runtime(sh): Update ftplugin (#12950)
Christian Brabandt <cb@256bit.org>
parents: 32976
diff changeset
48 if !has("gui_running") && executable("less")
33500
665078e8fea1 runtime(sh): Update ftplugin (#13213)
Christian Brabandt <cb@256bit.org>
parents: 33360
diff changeset
49 command! -buffer -nargs=1 ShKeywordPrg silent exe '!bash -c "{ help "<args>" 2>/dev/null || man "<args>"; } | LESS= less"' | redraw!
665078e8fea1 runtime(sh): Update ftplugin (#13213)
Christian Brabandt <cb@256bit.org>
parents: 33360
diff changeset
50 elseif has("terminal")
665078e8fea1 runtime(sh): Update ftplugin (#13213)
Christian Brabandt <cb@256bit.org>
parents: 33360
diff changeset
51 command! -buffer -nargs=1 ShKeywordPrg silent exe ':term bash -c "help "<args>" 2>/dev/null || man "<args>""'
32976
d23645a0aca8 runtime: configure keywordpg for some file types (#5566)
Christian Brabandt <cb@256bit.org>
parents: 30202
diff changeset
52 else
33500
665078e8fea1 runtime(sh): Update ftplugin (#13213)
Christian Brabandt <cb@256bit.org>
parents: 33360
diff changeset
53 command! -buffer -nargs=1 ShKeywordPrg echo system('bash -c "help <args>" 2>/dev/null || man "<args>"')
32976
d23645a0aca8 runtime: configure keywordpg for some file types (#5566)
Christian Brabandt <cb@256bit.org>
parents: 30202
diff changeset
54 endif
33500
665078e8fea1 runtime(sh): Update ftplugin (#13213)
Christian Brabandt <cb@256bit.org>
parents: 33360
diff changeset
55 setlocal keywordprg=:ShKeywordPrg
665078e8fea1 runtime(sh): Update ftplugin (#13213)
Christian Brabandt <cb@256bit.org>
parents: 33360
diff changeset
56 let b:undo_ftplugin ..= " | setl kp< | sil! delc -buffer ShKeywordPrg"
32976
d23645a0aca8 runtime: configure keywordpg for some file types (#5566)
Christian Brabandt <cb@256bit.org>
parents: 30202
diff changeset
57 endif
d23645a0aca8 runtime: configure keywordpg for some file types (#5566)
Christian Brabandt <cb@256bit.org>
parents: 30202
diff changeset
58
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
59 let &cpo = s:save_cpo
3410
94601b379f38 Updated runtime files. Add Dutch translations.
Bram Moolenaar <bram@vim.org>
parents: 2034
diff changeset
60 unlet s:save_cpo
30202
fee9eccee266 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 28010
diff changeset
61
fee9eccee266 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 28010
diff changeset
62 " vim: nowrap sw=2 sts=2 ts=8 noet: