annotate runtime/ftplugin/man.vim @ 21538:6e13105b5d07 v8.2.1319

patch 8.2.1319: status badge for Github CI has wrong link Commit: https://github.com/vim/vim/commit/ac7bf8c4bfcbb157a2db6b939927bf11edb6ba7b Author: Bram Moolenaar <Bram@vim.org> Date: Wed Jul 29 17:43:55 2020 +0200 patch 8.2.1319: status badge for Github CI has wrong link Problem: Status badge for Github CI has wrong link. Solution: Rename and use the right link
author Bram Moolenaar <Bram@vim.org>
date Wed, 29 Jul 2020 17:45:04 +0200
parents 661eb972cb22
children 5b7ea82bc18f
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>
20753
661eb972cb22 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 20317
diff changeset
5 " Last Change: 2020 Jun 01
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7 " To make the ":Man" command available before editing a manual page, source
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8 " this script from your startup vimrc file.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
9
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
10 " If 'filetype' isn't "man", we must have been called to only define ":Man".
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
11 if &filetype == "man"
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
12
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
13 " Only do this when not done yet for this buffer
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
14 if exists("b:did_ftplugin")
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
15 finish
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
16 endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
17 let b:did_ftplugin = 1
14421
2f7e67dd088c Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 13857
diff changeset
18 endif
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
19
14421
2f7e67dd088c Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 13857
diff changeset
20 let s:cpo_save = &cpo
2f7e67dd088c Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 13857
diff changeset
21 set cpo-=C
2f7e67dd088c Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 13857
diff changeset
22
2f7e67dd088c Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 13857
diff changeset
23 if &filetype == "man"
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
24 " allow dot and dash in manual page name.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
25 setlocal iskeyword+=\.,-
14421
2f7e67dd088c Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 13857
diff changeset
26 let b:undo_ftplugin = "setlocal iskeyword<"
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
27
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
28 " Add mappings, unless the user didn't want this.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
29 if !exists("no_plugin_maps") && !exists("no_man_maps")
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
30 if !hasmapto('<Plug>ManBS')
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
31 nmap <buffer> <LocalLeader>h <Plug>ManBS
14421
2f7e67dd088c Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 13857
diff changeset
32 let b:undo_ftplugin = b:undo_ftplugin
2f7e67dd088c Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 13857
diff changeset
33 \ . '|silent! nunmap <buffer> <LocalLeader>h'
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
34 endif
816
4a79d6d376f0 updated for version 7.0c02
vimboss
parents: 7
diff changeset
35 nnoremap <buffer> <Plug>ManBS :%s/.\b//g<CR>:setl nomod<CR>''
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
36
20753
661eb972cb22 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 20317
diff changeset
37 nnoremap <buffer> <silent> <c-]> :call <SID>PreGetPage(v:count)<CR>
661eb972cb22 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 20317
diff changeset
38 nnoremap <buffer> <silent> <c-t> :call <SID>PopPage()<CR>
7272
17333ebd2bbd commit https://github.com/vim/vim/commit/d042dc825c9b97dacd84d4728f88300da4d5b6b9
Christian Brabandt <cb@256bit.org>
parents: 6476
diff changeset
39 nnoremap <buffer> <silent> q :q<CR>
14421
2f7e67dd088c Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 13857
diff changeset
40
2f7e67dd088c Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 13857
diff changeset
41 " Add undo commands for the maps
2f7e67dd088c Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 13857
diff changeset
42 let b:undo_ftplugin = b:undo_ftplugin
2f7e67dd088c Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 13857
diff changeset
43 \ . '|silent! nunmap <buffer> <Plug>ManBS'
2f7e67dd088c Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 13857
diff changeset
44 \ . '|silent! nunmap <buffer> <c-]>'
2f7e67dd088c Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 13857
diff changeset
45 \ . '|silent! nunmap <buffer> <c-t>'
2f7e67dd088c Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 13857
diff changeset
46 \ . '|silent! nunmap <buffer> q'
7272
17333ebd2bbd commit https://github.com/vim/vim/commit/d042dc825c9b97dacd84d4728f88300da4d5b6b9
Christian Brabandt <cb@256bit.org>
parents: 6476
diff changeset
47 endif
17333ebd2bbd commit https://github.com/vim/vim/commit/d042dc825c9b97dacd84d4728f88300da4d5b6b9
Christian Brabandt <cb@256bit.org>
parents: 6476
diff changeset
48
17333ebd2bbd commit https://github.com/vim/vim/commit/d042dc825c9b97dacd84d4728f88300da4d5b6b9
Christian Brabandt <cb@256bit.org>
parents: 6476
diff changeset
49 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
50 setlocal foldmethod=indent foldnestmax=1 foldenable
14421
2f7e67dd088c Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 13857
diff changeset
51 let b:undo_ftplugin = b:undo_ftplugin
2f7e67dd088c Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 13857
diff changeset
52 \ . '|silent! setl fdm< fdn< fen<'
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
53 endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
54
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
55 endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
56
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
57 if exists(":Man") != 2
14421
2f7e67dd088c Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 13857
diff changeset
58 com -nargs=+ -complete=shellcmd Man call s:GetPage(<q-mods>, <f-args>)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
59 nmap <Leader>K :call <SID>PreGetPage(0)<CR>
10548
74effdaa369e Updated runtime files.
Christian Brabandt <cb@256bit.org>
parents: 9326
diff changeset
60 nmap <Plug>ManPreGetPage :call <SID>PreGetPage(0)<CR>
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
61 endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
62
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
63 " Define functions only once.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
64 if !exists("s:man_tag_depth")
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
65
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
66 let s:man_tag_depth = 0
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
67
1623
53938adac247 updated for version 7.2a
vimboss
parents: 1125
diff changeset
68 let s:man_sect_arg = ""
53938adac247 updated for version 7.2a
vimboss
parents: 1125
diff changeset
69 let s:man_find_arg = "-w"
53938adac247 updated for version 7.2a
vimboss
parents: 1125
diff changeset
70 try
53938adac247 updated for version 7.2a
vimboss
parents: 1125
diff changeset
71 if !has("win32") && $OSTYPE !~ 'cygwin\|linux' && system('uname -s') =~ "SunOS" && system('uname -r') =~ "^5"
53938adac247 updated for version 7.2a
vimboss
parents: 1125
diff changeset
72 let s:man_sect_arg = "-s"
53938adac247 updated for version 7.2a
vimboss
parents: 1125
diff changeset
73 let s:man_find_arg = "-l"
53938adac247 updated for version 7.2a
vimboss
parents: 1125
diff changeset
74 endif
53938adac247 updated for version 7.2a
vimboss
parents: 1125
diff changeset
75 catch /E145:/
53938adac247 updated for version 7.2a
vimboss
parents: 1125
diff changeset
76 " Ignore the error in restricted mode
53938adac247 updated for version 7.2a
vimboss
parents: 1125
diff changeset
77 endtry
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
78
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
79 func <SID>PreGetPage(cnt)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
80 if a:cnt == 0
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
81 let old_isk = &iskeyword
6369
c5d53d4c3e2e Update runtime files.
Bram Moolenaar <bram@vim.org>
parents: 5220
diff changeset
82 if &ft == 'man'
c5d53d4c3e2e Update runtime files.
Bram Moolenaar <bram@vim.org>
parents: 5220
diff changeset
83 setl iskeyword+=(,)
c5d53d4c3e2e Update runtime files.
Bram Moolenaar <bram@vim.org>
parents: 5220
diff changeset
84 endif
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
85 let str = expand("<cword>")
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
86 let &l:iskeyword = old_isk
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
87 let page = substitute(str, '(*\(\k\+\).*', '\1', '')
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
88 let sect = substitute(str, '\(\k\+\)(\([^()]*\)).*', '\2', '')
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
89 if match(sect, '^[0-9 ]\+$') == -1
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
90 let sect = ""
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
91 endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
92 if sect == page
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
93 let sect = ""
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
94 endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
95 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
96 let sect = a:cnt
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
97 let page = expand("<cword>")
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
98 endif
19813
350e1d3131d8 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 18186
diff changeset
99 call s:GetPage('', sect, page)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
100 endfunc
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
101
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
102 func <SID>GetCmdArg(sect, page)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
103 if a:sect == ''
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
104 return a:page
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
105 endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
106 return s:man_sect_arg.' '.a:sect.' '.a:page
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
107 endfunc
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
108
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
109 func <SID>FindPage(sect, page)
10734
523cd59d6db0 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 10548
diff changeset
110 let where = system("man ".s:man_find_arg.' '.s:GetCmdArg(a:sect, a:page))
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
111 if where !~ "^/"
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
112 if matchstr(where, " [^ ]*$") !~ "^ /"
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
113 return 0
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
114 endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
115 endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
116 return 1
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
117 endfunc
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
118
14421
2f7e67dd088c Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 13857
diff changeset
119 func <SID>GetPage(cmdmods, ...)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
120 if a:0 >= 2
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
121 let sect = a:1
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
122 let page = a:2
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
123 elseif a:0 >= 1
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
124 let sect = ""
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
125 let page = a:1
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
126 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
127 return
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
128 endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
129
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
130 " To support: nmap K :Man <cword>
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
131 if page == '<cword>'
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
132 let page = expand('<cword>')
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
133 endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
134
18186
03b854983b14 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 17541
diff changeset
135 if !exists('g:ft_man_no_sect_fallback') || (g:ft_man_no_sect_fallback == 0)
03b854983b14 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 17541
diff changeset
136 if sect != "" && s:FindPage(sect, page) == 0
03b854983b14 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 17541
diff changeset
137 let sect = ""
03b854983b14 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 17541
diff changeset
138 endif
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
139 endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
140 if s:FindPage(sect, page) == 0
20753
661eb972cb22 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 20317
diff changeset
141 let msg = 'man.vim: no manual entry for "' . page . '"'
661eb972cb22 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 20317
diff changeset
142 if !empty(sect)
661eb972cb22 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 20317
diff changeset
143 let msg .= ' in section ' . sect
18186
03b854983b14 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 17541
diff changeset
144 endif
20753
661eb972cb22 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 20317
diff changeset
145 echomsg msg
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
146 return
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
147 endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
148 exec "let s:man_tag_buf_".s:man_tag_depth." = ".bufnr("%")
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
149 exec "let s:man_tag_lin_".s:man_tag_depth." = ".line(".")
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
150 exec "let s:man_tag_col_".s:man_tag_depth." = ".col(".")
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
151 let s:man_tag_depth = s:man_tag_depth + 1
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
152
17470
d2a834aa7cc0 patch 8.1.1733: the man ftplugin leaves an empty buffer behind
Bram Moolenaar <Bram@vim.org>
parents: 15640
diff changeset
153 let open_cmd = 'edit'
d2a834aa7cc0 patch 8.1.1733: the man ftplugin leaves an empty buffer behind
Bram Moolenaar <Bram@vim.org>
parents: 15640
diff changeset
154
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
155 " Use an existing "man" window if it exists, otherwise open a new one.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
156 if &filetype != "man"
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
157 let thiswin = winnr()
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
158 exe "norm! \<C-W>b"
1125
96cd8222a819 updated for version 7.1a
vimboss
parents: 816
diff changeset
159 if winnr() > 1
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
160 exe "norm! " . thiswin . "\<C-W>w"
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
161 while 1
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
162 if &filetype == "man"
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
163 break
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
164 endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
165 exe "norm! \<C-W>w"
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
166 if thiswin == winnr()
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
167 break
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
168 endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
169 endwhile
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
170 endif
1125
96cd8222a819 updated for version 7.1a
vimboss
parents: 816
diff changeset
171 if &filetype != "man"
9326
cd9c4bbe1d03 commit https://github.com/vim/vim/commit/ddf8d1c746ee081d15c9d7e0515f6ac43adbf363
Christian Brabandt <cb@256bit.org>
parents: 7992
diff changeset
172 if exists("g:ft_man_open_mode")
17470
d2a834aa7cc0 patch 8.1.1733: the man ftplugin leaves an empty buffer behind
Bram Moolenaar <Bram@vim.org>
parents: 15640
diff changeset
173 if g:ft_man_open_mode == 'vert'
d2a834aa7cc0 patch 8.1.1733: the man ftplugin leaves an empty buffer behind
Bram Moolenaar <Bram@vim.org>
parents: 15640
diff changeset
174 let open_cmd = 'vsplit'
d2a834aa7cc0 patch 8.1.1733: the man ftplugin leaves an empty buffer behind
Bram Moolenaar <Bram@vim.org>
parents: 15640
diff changeset
175 elseif g:ft_man_open_mode == 'tab'
d2a834aa7cc0 patch 8.1.1733: the man ftplugin leaves an empty buffer behind
Bram Moolenaar <Bram@vim.org>
parents: 15640
diff changeset
176 let open_cmd = 'tabedit'
9326
cd9c4bbe1d03 commit https://github.com/vim/vim/commit/ddf8d1c746ee081d15c9d7e0515f6ac43adbf363
Christian Brabandt <cb@256bit.org>
parents: 7992
diff changeset
177 else
17470
d2a834aa7cc0 patch 8.1.1733: the man ftplugin leaves an empty buffer behind
Bram Moolenaar <Bram@vim.org>
parents: 15640
diff changeset
178 let open_cmd = 'split'
9326
cd9c4bbe1d03 commit https://github.com/vim/vim/commit/ddf8d1c746ee081d15c9d7e0515f6ac43adbf363
Christian Brabandt <cb@256bit.org>
parents: 7992
diff changeset
179 endif
cd9c4bbe1d03 commit https://github.com/vim/vim/commit/ddf8d1c746ee081d15c9d7e0515f6ac43adbf363
Christian Brabandt <cb@256bit.org>
parents: 7992
diff changeset
180 else
17470
d2a834aa7cc0 patch 8.1.1733: the man ftplugin leaves an empty buffer behind
Bram Moolenaar <Bram@vim.org>
parents: 15640
diff changeset
181 let open_cmd = a:cmdmods . ' split'
9326
cd9c4bbe1d03 commit https://github.com/vim/vim/commit/ddf8d1c746ee081d15c9d7e0515f6ac43adbf363
Christian Brabandt <cb@256bit.org>
parents: 7992
diff changeset
182 endif
1125
96cd8222a819 updated for version 7.1a
vimboss
parents: 816
diff changeset
183 endif
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
184 endif
17470
d2a834aa7cc0 patch 8.1.1733: the man ftplugin leaves an empty buffer behind
Bram Moolenaar <Bram@vim.org>
parents: 15640
diff changeset
185
d2a834aa7cc0 patch 8.1.1733: the man ftplugin leaves an empty buffer behind
Bram Moolenaar <Bram@vim.org>
parents: 15640
diff changeset
186 silent execute open_cmd . " $HOME/" . page . '.' . sect . '~'
d2a834aa7cc0 patch 8.1.1733: the man ftplugin leaves an empty buffer behind
Bram Moolenaar <Bram@vim.org>
parents: 15640
diff changeset
187
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
188 " Avoid warning for editing the dummy file twice
816
4a79d6d376f0 updated for version 7.0c02
vimboss
parents: 7
diff changeset
189 setl buftype=nofile noswapfile
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
190
17541
d9aa921b7198 patch 8.1.1768: man plugin changes setting in current window
Bram Moolenaar <Bram@vim.org>
parents: 17470
diff changeset
191 setl fdc=0 ma nofen nonu nornu
20025
18043e7ab449 patch 8.2.0568: the man filetype plugin overwrites the unnamed register
Bram Moolenaar <Bram@vim.org>
parents: 19968
diff changeset
192 %delete _
9326
cd9c4bbe1d03 commit https://github.com/vim/vim/commit/ddf8d1c746ee081d15c9d7e0515f6ac43adbf363
Christian Brabandt <cb@256bit.org>
parents: 7992
diff changeset
193 let unsetwidth = 0
7992
78106b0f2c56 commit https://github.com/vim/vim/commit/cbebd4879cc78e670d79b2c57dc33d7b911c962a
Christian Brabandt <cb@256bit.org>
parents: 7272
diff changeset
194 if empty($MANWIDTH)
78106b0f2c56 commit https://github.com/vim/vim/commit/cbebd4879cc78e670d79b2c57dc33d7b911c962a
Christian Brabandt <cb@256bit.org>
parents: 7272
diff changeset
195 let $MANWIDTH = winwidth(0)
9326
cd9c4bbe1d03 commit https://github.com/vim/vim/commit/ddf8d1c746ee081d15c9d7e0515f6ac43adbf363
Christian Brabandt <cb@256bit.org>
parents: 7992
diff changeset
196 let unsetwidth = 1
7992
78106b0f2c56 commit https://github.com/vim/vim/commit/cbebd4879cc78e670d79b2c57dc33d7b911c962a
Christian Brabandt <cb@256bit.org>
parents: 7272
diff changeset
197 endif
12826
f690da1b3c04 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 10734
diff changeset
198
f690da1b3c04 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 10734
diff changeset
199 " Ensure Vim is not recursively invoked (man-db does this) when doing ctrl-[
f690da1b3c04 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 10734
diff changeset
200 " on a man page reference by unsetting MANPAGER.
13125
371ceeebbdaa Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 12826
diff changeset
201 " Some versions of env(1) do not support the '-u' option, and in such case
371ceeebbdaa Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 12826
diff changeset
202 " we set MANPAGER=cat.
371ceeebbdaa Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 12826
diff changeset
203 if !exists('s:env_has_u')
371ceeebbdaa Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 12826
diff changeset
204 call system('env -u x true')
371ceeebbdaa Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 12826
diff changeset
205 let s:env_has_u = (v:shell_error == 0)
371ceeebbdaa Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 12826
diff changeset
206 endif
371ceeebbdaa Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 12826
diff changeset
207 let env_cmd = s:env_has_u ? 'env -u MANPAGER' : 'env MANPAGER=cat'
19968
1908e92b02fd Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 19813
diff changeset
208 let env_cmd .= ' GROFF_NO_SGR=1'
20317
2334bf788e8a Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 20241
diff changeset
209 let man_cmd = env_cmd . ' man ' . s:GetCmdArg(sect, page) . ' | col -b'
13125
371ceeebbdaa Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 12826
diff changeset
210 silent exec "r !" . man_cmd
12826
f690da1b3c04 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 10734
diff changeset
211
9326
cd9c4bbe1d03 commit https://github.com/vim/vim/commit/ddf8d1c746ee081d15c9d7e0515f6ac43adbf363
Christian Brabandt <cb@256bit.org>
parents: 7992
diff changeset
212 if unsetwidth
cd9c4bbe1d03 commit https://github.com/vim/vim/commit/ddf8d1c746ee081d15c9d7e0515f6ac43adbf363
Christian Brabandt <cb@256bit.org>
parents: 7992
diff changeset
213 let $MANWIDTH = ''
cd9c4bbe1d03 commit https://github.com/vim/vim/commit/ddf8d1c746ee081d15c9d7e0515f6ac43adbf363
Christian Brabandt <cb@256bit.org>
parents: 7992
diff changeset
214 endif
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
215 " Remove blank lines from top and bottom.
15640
7cfe57329284 Updated runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 14421
diff changeset
216 while line('$') > 1 && getline(1) =~ '^\s*$'
20025
18043e7ab449 patch 8.2.0568: the man filetype plugin overwrites the unnamed register
Bram Moolenaar <Bram@vim.org>
parents: 19968
diff changeset
217 1delete _
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
218 endwhile
15640
7cfe57329284 Updated runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 14421
diff changeset
219 while line('$') > 1 && getline('$') =~ '^\s*$'
20025
18043e7ab449 patch 8.2.0568: the man filetype plugin overwrites the unnamed register
Bram Moolenaar <Bram@vim.org>
parents: 19968
diff changeset
220 $delete _
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
221 endwhile
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
222 1
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
223 setl ft=man nomod
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
224 setl bufhidden=hide
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
225 setl nobuflisted
9326
cd9c4bbe1d03 commit https://github.com/vim/vim/commit/ddf8d1c746ee081d15c9d7e0515f6ac43adbf363
Christian Brabandt <cb@256bit.org>
parents: 7992
diff changeset
226 setl noma
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
227 endfunc
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
228
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
229 func <SID>PopPage()
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
230 if s:man_tag_depth > 0
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
231 let s:man_tag_depth = s:man_tag_depth - 1
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
232 exec "let s:man_tag_buf=s:man_tag_buf_".s:man_tag_depth
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
233 exec "let s:man_tag_lin=s:man_tag_lin_".s:man_tag_depth
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
234 exec "let s:man_tag_col=s:man_tag_col_".s:man_tag_depth
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
235 exec s:man_tag_buf."b"
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
236 exec s:man_tag_lin
13857
e751b5c9dff3 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 13125
diff changeset
237 exec "norm! ".s:man_tag_col."|"
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
238 exec "unlet s:man_tag_buf_".s:man_tag_depth
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
239 exec "unlet s:man_tag_lin_".s:man_tag_depth
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
240 exec "unlet s:man_tag_col_".s:man_tag_depth
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
241 unlet s:man_tag_buf s:man_tag_lin s:man_tag_col
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
242 endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
243 endfunc
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
244
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
245 endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
246
14421
2f7e67dd088c Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 13857
diff changeset
247 let &cpo = s:cpo_save
2f7e67dd088c Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 13857
diff changeset
248 unlet s:cpo_save
2f7e67dd088c Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 13857
diff changeset
249
9326
cd9c4bbe1d03 commit https://github.com/vim/vim/commit/ddf8d1c746ee081d15c9d7e0515f6ac43adbf363
Christian Brabandt <cb@256bit.org>
parents: 7992
diff changeset
250 " vim: set sw=2 ts=8 noet: