Skip to content

Commit 8ab2fd8

Browse files
committed
Merge remote-tracking branch 'vim/master'
2 parents c981dc1 + 12a4940 commit 8ab2fd8

43 files changed

Lines changed: 4870 additions & 420 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

runtime/autoload/dist/man.vim

Lines changed: 196 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,196 @@
1+
" Vim filetype plugin autoload file
2+
" Language: man
3+
" Maintainer: Jason Franklin <[email protected]>
4+
" Maintainer: SungHyun Nam <[email protected]>
5+
" Autoload Split: Bram Moolenaar
6+
" Last Change: 2022 Jun 18
7+
8+
let s:cpo_save = &cpo
9+
set cpo-=C
10+
11+
let s:man_tag_depth = 0
12+
13+
let s:man_sect_arg = ""
14+
let s:man_find_arg = "-w"
15+
try
16+
if !has("win32") && $OSTYPE !~ 'cygwin\|linux' && system('uname -s') =~ "SunOS" && system('uname -r') =~ "^5"
17+
let s:man_sect_arg = "-s"
18+
let s:man_find_arg = "-l"
19+
endif
20+
catch /E145:/
21+
" Ignore the error in restricted mode
22+
endtry
23+
24+
func dist#man#PreGetPage(cnt)
25+
if a:cnt == 0
26+
let old_isk = &iskeyword
27+
if &ft == 'man'
28+
setl iskeyword+=(,)
29+
endif
30+
let str = expand("<cword>")
31+
let &l:iskeyword = old_isk
32+
let page = substitute(str, '(*\(\k\+\).*', '\1', '')
33+
let sect = substitute(str, '\(\k\+\)(\([^()]*\)).*', '\2', '')
34+
if match(sect, '^[0-9 ]\+$') == -1
35+
let sect = ""
36+
endif
37+
if sect == page
38+
let sect = ""
39+
endif
40+
else
41+
let sect = a:cnt
42+
let page = expand("<cword>")
43+
endif
44+
call dist#man#GetPage('', sect, page)
45+
endfunc
46+
47+
func s:GetCmdArg(sect, page)
48+
49+
if empty(a:sect)
50+
return shellescape(a:page)
51+
endif
52+
53+
return s:man_sect_arg . ' ' . shellescape(a:sect) . ' ' . shellescape(a:page)
54+
endfunc
55+
56+
func s:FindPage(sect, page)
57+
let l:cmd = printf('man %s %s', s:man_find_arg, s:GetCmdArg(a:sect, a:page))
58+
call system(l:cmd)
59+
60+
if v:shell_error
61+
return 0
62+
endif
63+
64+
return 1
65+
endfunc
66+
67+
func dist#man#GetPage(cmdmods, ...)
68+
if a:0 >= 2
69+
let sect = a:1
70+
let page = a:2
71+
elseif a:0 >= 1
72+
let sect = ""
73+
let page = a:1
74+
else
75+
return
76+
endif
77+
78+
" To support: nmap K :Man <cword>
79+
if page == '<cword>'
80+
let page = expand('<cword>')
81+
endif
82+
83+
if !exists('g:ft_man_no_sect_fallback') || (g:ft_man_no_sect_fallback == 0)
84+
if sect != "" && s:FindPage(sect, page) == 0
85+
let sect = ""
86+
endif
87+
endif
88+
if s:FindPage(sect, page) == 0
89+
let msg = 'man.vim: no manual entry for "' . page . '"'
90+
if !empty(sect)
91+
let msg .= ' in section ' . sect
92+
endif
93+
echomsg msg
94+
return
95+
endif
96+
exec "let s:man_tag_buf_".s:man_tag_depth." = ".bufnr("%")
97+
exec "let s:man_tag_lin_".s:man_tag_depth." = ".line(".")
98+
exec "let s:man_tag_col_".s:man_tag_depth." = ".col(".")
99+
let s:man_tag_depth = s:man_tag_depth + 1
100+
101+
let open_cmd = 'edit'
102+
103+
" Use an existing "man" window if it exists, otherwise open a new one.
104+
if &filetype != "man"
105+
let thiswin = winnr()
106+
exe "norm! \<C-W>b"
107+
if winnr() > 1
108+
exe "norm! " . thiswin . "\<C-W>w"
109+
while 1
110+
if &filetype == "man"
111+
break
112+
endif
113+
exe "norm! \<C-W>w"
114+
if thiswin == winnr()
115+
break
116+
endif
117+
endwhile
118+
endif
119+
if &filetype != "man"
120+
if exists("g:ft_man_open_mode")
121+
if g:ft_man_open_mode == 'vert'
122+
let open_cmd = 'vsplit'
123+
elseif g:ft_man_open_mode == 'tab'
124+
let open_cmd = 'tabedit'
125+
else
126+
let open_cmd = 'split'
127+
endif
128+
else
129+
let open_cmd = a:cmdmods . ' split'
130+
endif
131+
endif
132+
endif
133+
134+
silent execute open_cmd . " $HOME/" . page . '.' . sect . '~'
135+
136+
" Avoid warning for editing the dummy file twice
137+
setl buftype=nofile noswapfile
138+
139+
setl fdc=0 ma nofen nonu nornu
140+
%delete _
141+
let unsetwidth = 0
142+
if empty($MANWIDTH)
143+
let $MANWIDTH = winwidth(0)
144+
let unsetwidth = 1
145+
endif
146+
147+
" Ensure Vim is not recursively invoked (man-db does this) when doing ctrl-[
148+
" on a man page reference by unsetting MANPAGER.
149+
" Some versions of env(1) do not support the '-u' option, and in such case
150+
" we set MANPAGER=cat.
151+
if !exists('s:env_has_u')
152+
call system('env -u x true')
153+
let s:env_has_u = (v:shell_error == 0)
154+
endif
155+
let env_cmd = s:env_has_u ? 'env -u MANPAGER' : 'env MANPAGER=cat'
156+
let env_cmd .= ' GROFF_NO_SGR=1'
157+
let man_cmd = env_cmd . ' man ' . s:GetCmdArg(sect, page) . ' | col -b'
158+
silent exec "r !" . man_cmd
159+
160+
if unsetwidth
161+
let $MANWIDTH = ''
162+
endif
163+
" Remove blank lines from top and bottom.
164+
while line('$') > 1 && getline(1) =~ '^\s*$'
165+
1delete _
166+
endwhile
167+
while line('$') > 1 && getline('$') =~ '^\s*$'
168+
$delete _
169+
endwhile
170+
1
171+
setl ft=man nomod
172+
setl bufhidden=hide
173+
setl nobuflisted
174+
setl noma
175+
endfunc
176+
177+
func dist#man#PopPage()
178+
if s:man_tag_depth > 0
179+
let s:man_tag_depth = s:man_tag_depth - 1
180+
exec "let s:man_tag_buf=s:man_tag_buf_".s:man_tag_depth
181+
exec "let s:man_tag_lin=s:man_tag_lin_".s:man_tag_depth
182+
exec "let s:man_tag_col=s:man_tag_col_".s:man_tag_depth
183+
exec s:man_tag_buf."b"
184+
exec s:man_tag_lin
185+
exec "norm! ".s:man_tag_col."|"
186+
exec "unlet s:man_tag_buf_".s:man_tag_depth
187+
exec "unlet s:man_tag_lin_".s:man_tag_depth
188+
exec "unlet s:man_tag_col_".s:man_tag_depth
189+
unlet s:man_tag_buf s:man_tag_lin s:man_tag_col
190+
endif
191+
endfunc
192+
193+
let &cpo = s:cpo_save
194+
unlet s:cpo_save
195+
196+
" vim: set sw=2 ts=8 noet:

runtime/doc/builtin.txt

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
*builtin.txt* For Vim version 8.2. Last change: 2022 Jun 16
1+
*builtin.txt* For Vim version 8.2. Last change: 2022 Jun 17
22

33

44
VIM REFERENCE MANUAL by Bram Moolenaar
@@ -2869,7 +2869,7 @@ fnamemodify({fname}, {mods}) *fnamemodify()*
28692869
Example: >
28702870
:echo fnamemodify("main.c", ":p:h")
28712871
< results in: >
2872-
/home/mool/vim/vim/src
2872+
/home/user/vim/vim/src
28732873
< If {mods} is empty or an unsupported modifier is used then
28742874
{fname} is returned.
28752875
Note: Environment variables don't work in {fname}, use
@@ -10022,8 +10022,6 @@ win_gettype([{nr}]) *win_gettype()*
1002210022
popup window then 'buftype' is "terminal" and win_gettype()
1002310023
returns "popup".
1002410024

10025-
Return an empty string if the window cannot be found.
10026-
1002710025
Can also be used as a |method|: >
1002810026
GetWinid()->win_gettype()
1002910027
<

runtime/doc/eval.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
*eval.txt* For Vim version 8.2. Last change: 2022 Jun 03
1+
*eval.txt* For Vim version 8.2. Last change: 2022 Jun 17
22

33

44
VIM REFERENCE MANUAL by Bram Moolenaar
@@ -531,7 +531,7 @@ entry. Note that the String '04' and the Number 04 are different, since the
531531
Number will be converted to the String '4', leading zeros are dropped. The
532532
empty string can also be used as a key.
533533

534-
In |Vim9| script literally keys can be used if the key consists of alphanumeric
534+
In |Vim9| script a literal key can be used if it consists only of alphanumeric
535535
characters, underscore and dash, see |vim9-literal-dict|.
536536
*literal-Dict* *#{}*
537537
To avoid having to put quotes around every key the #{} form can be used in

runtime/doc/map.txt

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
*map.txt* For Vim version 8.2. Last change: 2022 Jun 14
1+
*map.txt* For Vim version 8.2. Last change: 2022 Jun 18
22

33

44
VIM REFERENCE MANUAL by Bram Moolenaar
@@ -394,15 +394,7 @@ Note:
394394
mapping is recursive.
395395
- In Visual mode you can use `line('v')` and `col('v')` to get one end of the
396396
Visual area, the cursor is at the other end.
397-
- In Select mode, |:map| and |:vmap| command mappings are executed in
398-
Visual mode. Use |:smap| to handle Select mode differently. One particular
399-
edge case: >
400-
:vnoremap <C-K> <Esc>
401-
< This ends Visual mode when in Visual mode, but in Select mode it does not
402-
work, because Select mode is restored after executing the mapped keys. You
403-
need to use: >
404-
:snoremap <C-K> <Esc>
405-
<
397+
406398
*E1255* *E1136*
407399
<Cmd> and <ScriptCmd> commands must terminate, that is, they must be followed
408400
by <CR> in the {rhs} of the mapping definition. |Command-line| mode is never

runtime/doc/repeat.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
*repeat.txt* For Vim version 8.2. Last change: 2022 Apr 08
1+
*repeat.txt* For Vim version 8.2. Last change: 2022 Jun 18
22

33

44
VIM REFERENCE MANUAL by Bram Moolenaar
@@ -197,7 +197,7 @@ For writing a Vim script, see chapter 41 of the user manual |usr_41.txt|.
197197
:so[urce] {file} Read Ex commands from {file}. These are commands that
198198
start with a ":".
199199
Triggers the |SourcePre| autocommand.
200-
200+
*:source-range*
201201
:[range]so[urce] [++clear]
202202
Read Ex commands from the [range] of lines in the
203203
current buffer.

runtime/doc/tags

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3224,6 +3224,7 @@ $quote eval.txt /*$quote*
32243224
:sort change.txt /*:sort*
32253225
:source repeat.txt /*:source*
32263226
:source! repeat.txt /*:source!*
3227+
:source-range repeat.txt /*:source-range*
32273228
:source_crnl repeat.txt /*:source_crnl*
32283229
:sp windows.txt /*:sp*
32293230
:spe spell.txt /*:spe*
@@ -5527,6 +5528,7 @@ SpellFileMissing autocmd.txt /*SpellFileMissing*
55275528
StdinReadPost autocmd.txt /*StdinReadPost*
55285529
StdinReadPre autocmd.txt /*StdinReadPre*
55295530
String eval.txt /*String*
5531+
Sven-Guckes version9.txt /*Sven-Guckes*
55305532
SwapExists autocmd.txt /*SwapExists*
55315533
Syntax autocmd.txt /*Syntax*
55325534
SystemColors.plist gui_mac.txt /*SystemColors.plist*

0 commit comments

Comments
 (0)