annotate runtime/ftplugin/man.vim @ 35122:739aaccbca74 default tip

runtime(sh,zsh): clear $MANPAGER in ftplugin before shelling out Commit: https://github.com/vim/vim/commit/8d8cb45756cb7e6fda17013b8347be3a11b29610 Author: D. Ben Knoble <ben.knoble+github@gmail.com> Date: Mon May 6 19:52:53 2024 +0200 runtime(sh,zsh): clear $MANPAGER in ftplugin before shelling out Say you use Vim and set MANPAGER='vim -M +MANPAGER --not-a-term -'; then :{Zs,S}hKeywordPrg (or K) will crap out and spew terminal garbage into less when bash's "help" fails. This was introduced by 2f25e40b1 (runtime: configure keywordpg for some file types (#5566), 2023-08-23) and may be present in other files touched by that commit. Make the "man" invocation sensible by unsetting MANPAGER in the environment. Note that changing MANPAGER for `:terminal` is not needed; Vim within Vim is perfectly fine. closes: #14679 Signed-off-by: D. Ben Knoble <ben.knoble+github@gmail.com> Signed-off-by: Christian Brabandt <cb@256bit.org>
author Christian Brabandt <cb@256bit.org>
date Mon, 06 May 2024 20:00:09 +0200
parents b2e8663e6dcc
children
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
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2 " Language: man
20241
56265f711890 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 20025
diff changeset
3 " Maintainer: Jason Franklin <vim@justemail.net>
20317
2334bf788e8a Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 20241
diff changeset
4 " Maintainer: SungHyun Nam <goweol@gmail.com>
29236
0eef32b4ebbc Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 25880
diff changeset
5 " Autoload Split: Bram Moolenaar
32294
b2e8663e6dcc Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 30634
diff changeset
6 " Last Change: 2023 Mar 21
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8 " To make the ":Man" command available before editing a manual page, source
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
9 " this script from your startup vimrc file.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
10
29236
0eef32b4ebbc Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 25880
diff changeset
11 " If 'filetype' isn't "man", we must have been called to define ":Man" and not
0eef32b4ebbc Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 25880
diff changeset
12 " to do the filetype plugin stuff.
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
13 if &filetype == "man"
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
14
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
15 " Only do this when not done yet for this buffer
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
16 if exists("b:did_ftplugin")
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
17 finish
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
18 endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
19 let b:did_ftplugin = 1
14421
2f7e67dd088c Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 13857
diff changeset
20 endif
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
21
14421
2f7e67dd088c Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 13857
diff changeset
22 let s:cpo_save = &cpo
2f7e67dd088c Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 13857
diff changeset
23 set cpo-=C
2f7e67dd088c Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 13857
diff changeset
24
2f7e67dd088c Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 13857
diff changeset
25 if &filetype == "man"
30634
f68f43043842 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 29236
diff changeset
26 " Allow hyphen, plus, colon, dot, and commercial at in manual page name.
32294
b2e8663e6dcc Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 30634
diff changeset
27 " Parentheses are not here but in dist#man#PreGetPage()
b2e8663e6dcc Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 30634
diff changeset
28 setlocal iskeyword=48-57,_,a-z,A-Z,-,+,:,.,@-@
14421
2f7e67dd088c Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 13857
diff changeset
29 let b:undo_ftplugin = "setlocal iskeyword<"
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
30
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
31 " Add mappings, unless the user didn't want this.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
32 if !exists("no_plugin_maps") && !exists("no_man_maps")
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
33 if !hasmapto('<Plug>ManBS')
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
34 nmap <buffer> <LocalLeader>h <Plug>ManBS
14421
2f7e67dd088c Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 13857
diff changeset
35 let b:undo_ftplugin = b:undo_ftplugin
2f7e67dd088c Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 13857
diff changeset
36 \ . '|silent! nunmap <buffer> <LocalLeader>h'
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
37 endif
816
4a79d6d376f0 updated for version 7.0c02
vimboss
parents: 7
diff changeset
38 nnoremap <buffer> <Plug>ManBS :%s/.\b//g<CR>:setl nomod<CR>''
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
39
29236
0eef32b4ebbc Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 25880
diff changeset
40 nnoremap <buffer> <silent> <c-]> :call dist#man#PreGetPage(v:count)<CR>
0eef32b4ebbc Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 25880
diff changeset
41 nnoremap <buffer> <silent> <c-t> :call dist#man#PopPage()<CR>
7272
17333ebd2bbd commit https://github.com/vim/vim/commit/d042dc825c9b97dacd84d4728f88300da4d5b6b9
Christian Brabandt <cb@256bit.org>
parents: 6476
diff changeset
42 nnoremap <buffer> <silent> q :q<CR>
14421
2f7e67dd088c Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 13857
diff changeset
43
2f7e67dd088c Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 13857
diff changeset
44 " Add undo commands for the maps
2f7e67dd088c Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 13857
diff changeset
45 let b:undo_ftplugin = b:undo_ftplugin
2f7e67dd088c Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 13857
diff changeset
46 \ . '|silent! nunmap <buffer> <Plug>ManBS'
2f7e67dd088c Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 13857
diff changeset
47 \ . '|silent! nunmap <buffer> <c-]>'
2f7e67dd088c Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 13857
diff changeset
48 \ . '|silent! nunmap <buffer> <c-t>'
2f7e67dd088c Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 13857
diff changeset
49 \ . '|silent! nunmap <buffer> q'
7272
17333ebd2bbd commit https://github.com/vim/vim/commit/d042dc825c9b97dacd84d4728f88300da4d5b6b9
Christian Brabandt <cb@256bit.org>
parents: 6476
diff changeset
50 endif
17333ebd2bbd commit https://github.com/vim/vim/commit/d042dc825c9b97dacd84d4728f88300da4d5b6b9
Christian Brabandt <cb@256bit.org>
parents: 6476
diff changeset
51
17333ebd2bbd commit https://github.com/vim/vim/commit/d042dc825c9b97dacd84d4728f88300da4d5b6b9
Christian Brabandt <cb@256bit.org>
parents: 6476
diff changeset
52 if exists('g:ft_man_folding_enable') && (g:ft_man_folding_enable == 1)
17333ebd2bbd commit https://github.com/vim/vim/commit/d042dc825c9b97dacd84d4728f88300da4d5b6b9
Christian Brabandt <cb@256bit.org>
parents: 6476
diff changeset
53 setlocal foldmethod=indent foldnestmax=1 foldenable
14421
2f7e67dd088c Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 13857
diff changeset
54 let b:undo_ftplugin = b:undo_ftplugin
2f7e67dd088c Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 13857
diff changeset
55 \ . '|silent! setl fdm< fdn< fen<'
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
56 endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
57
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
58 endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
59
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
60 if exists(":Man") != 2
29236
0eef32b4ebbc Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 25880
diff changeset
61 com -nargs=+ -complete=shellcmd Man call dist#man#GetPage(<q-mods>, <f-args>)
0eef32b4ebbc Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 25880
diff changeset
62 nmap <Leader>K :call dist#man#PreGetPage(0)<CR>
0eef32b4ebbc Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 25880
diff changeset
63 nmap <Plug>ManPreGetPage :call dist#man#PreGetPage(0)<CR>
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
64 endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
65
14421
2f7e67dd088c Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 13857
diff changeset
66 let &cpo = s:cpo_save
2f7e67dd088c Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 13857
diff changeset
67 unlet s:cpo_save
2f7e67dd088c Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 13857
diff changeset
68
9326
cd9c4bbe1d03 commit https://github.com/vim/vim/commit/ddf8d1c746ee081d15c9d7e0515f6ac43adbf363
Christian Brabandt <cb@256bit.org>
parents: 7992
diff changeset
69 " vim: set sw=2 ts=8 noet: