Skip to content

Commit 984a905

Browse files
committed
Merge remote-tracking branch 'vim/master'
2 parents 802731e + 2573af3 commit 984a905

111 files changed

Lines changed: 4740 additions & 1337 deletions

File tree

Some content is hidden

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

runtime/autoload/xmlformat.vim

Lines changed: 43 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
" Vim plugin for formatting XML
2-
" Last Change: 2019 Oct 24
3-
" Version: 0.2
2+
" Last Change: 2020 Jan 06
3+
" Version: 0.3
44
" Author: Christian Brabandt <[email protected]>
55
" Repository: https://github.com/chrisbra/vim-xml-ftplugin
66
" License: VIM License
@@ -15,7 +15,7 @@ let s:keepcpo = &cpo
1515
set cpo&vim
1616

1717
" Main function: Format the input {{{1
18-
func! xmlformat#Format()
18+
func! xmlformat#Format() abort
1919
" only allow reformatting through the gq command
2020
" (e.g. Vim is in normal mode)
2121
if mode() != 'n'
@@ -40,14 +40,16 @@ func! xmlformat#Format()
4040
continue
4141
elseif line !~# '<[/]\?[^>]*>'
4242
let nextmatch = match(list, '<[/]\?[^>]*>', current)
43-
let line .= join(list[(current + 1):(nextmatch-1)], "\n")
44-
call remove(list, current+1, nextmatch-1)
43+
if nextmatch > -1
44+
let line .= ' '. join(list[(current + 1):(nextmatch-1)], " ")
45+
call remove(list, current+1, nextmatch-1)
46+
endif
4547
endif
4648
" split on `>`, but don't split on very first opening <
4749
" this means, items can be like ['<tag>', 'tag content</tag>']
4850
for item in split(line, '.\@<=[>]\zs')
4951
if s:EndTag(item)
50-
let s:indent = s:DecreaseIndent()
52+
call s:DecreaseIndent()
5153
call add(result, s:Indent(item))
5254
elseif s:EmptyTag(lastitem)
5355
call add(result, s:Indent(item))
@@ -59,13 +61,23 @@ func! xmlformat#Format()
5961
" Simply split on '<', if there is one,
6062
" but reformat according to &textwidth
6163
let t=split(item, '.<\@=\zs')
64+
65+
" if the content fits well within a single line, add it there
66+
" so that the output looks like this:
67+
"
68+
" <foobar>1</foobar>
69+
if s:TagContent(lastitem) is# s:TagContent(t[1]) && strlen(result[-1]) + strlen(item) <= s:Textwidth()
70+
let result[-1] .= item
71+
let lastitem = t[1]
72+
continue
73+
endif
6274
" t should only contain 2 items, but just be safe here
6375
if s:IsTag(lastitem)
6476
let s:indent+=1
6577
endif
6678
let result+=s:FormatContent([t[0]])
6779
if s:EndTag(t[1])
68-
let s:indent = s:DecreaseIndent()
80+
call s:DecreaseIndent()
6981
endif
7082
"for y in t[1:]
7183
let result+=s:FormatContent(t[1:])
@@ -97,60 +109,69 @@ func! xmlformat#Format()
97109
return 0
98110
endfunc
99111
" Check if given tag is XML Declaration header {{{1
100-
func! s:IsXMLDecl(tag)
112+
func! s:IsXMLDecl(tag) abort
101113
return a:tag =~? '^\s*<?xml\s\?\%(version="[^"]*"\)\?\s\?\%(encoding="[^"]*"\)\? ?>\s*$'
102114
endfunc
103115
" Return tag indented by current level {{{1
104-
func! s:Indent(item)
116+
func! s:Indent(item) abort
105117
return repeat(' ', shiftwidth()*s:indent). s:Trim(a:item)
106118
endfu
107119
" Return item trimmed from leading whitespace {{{1
108-
func! s:Trim(item)
120+
func! s:Trim(item) abort
109121
if exists('*trim')
110122
return trim(a:item)
111123
else
112124
return matchstr(a:item, '\S\+.*')
113125
endif
114126
endfunc
115127
" Check if tag is a new opening tag <tag> {{{1
116-
func! s:StartTag(tag)
128+
func! s:StartTag(tag) abort
117129
let is_comment = s:IsComment(a:tag)
118130
return a:tag =~? '^\s*<[^/?]' && !is_comment
119131
endfunc
120132
" Check if tag is a Comment start {{{1
121-
func! s:IsComment(tag)
133+
func! s:IsComment(tag) abort
122134
return a:tag =~? '<!--'
123135
endfunc
124136
" Remove one level of indentation {{{1
125-
func! s:DecreaseIndent()
126-
return (s:indent > 0 ? s:indent - 1 : 0)
137+
func! s:DecreaseIndent() abort
138+
let s:indent = (s:indent > 0 ? s:indent - 1 : 0)
127139
endfunc
128140
" Check if tag is a closing tag </tag> {{{1
129-
func! s:EndTag(tag)
141+
func! s:EndTag(tag) abort
130142
return a:tag =~? '^\s*</'
131143
endfunc
132144
" Check that the tag is actually a tag and not {{{1
133145
" something like "foobar</foobar>"
134-
func! s:IsTag(tag)
146+
func! s:IsTag(tag) abort
135147
return s:Trim(a:tag)[0] == '<'
136148
endfunc
137149
" Check if tag is empty <tag/> {{{1
138-
func! s:EmptyTag(tag)
150+
func! s:EmptyTag(tag) abort
139151
return a:tag =~ '/>\s*$'
140152
endfunc
153+
func! s:TagContent(tag) abort "{{{1
154+
" Return content of a tag
155+
return substitute(a:tag, '^\s*<[/]\?\([^>]*\)>\s*$', '\1', '')
156+
endfunc
157+
func! s:Textwidth() abort "{{{1
158+
" return textwidth (or 80 if not set)
159+
return &textwidth == 0 ? 80 : &textwidth
160+
endfunc
141161
" Format input line according to textwidth {{{1
142-
func! s:FormatContent(list)
162+
func! s:FormatContent(list) abort
143163
let result=[]
144-
let limit = 80
145-
if &textwidth > 0
146-
let limit = &textwidth
147-
endif
164+
let limit = s:Textwidth()
148165
let column=0
149166
let idx = -1
150167
let add_indent = 0
151168
let cnt = 0
152169
for item in a:list
153170
for word in split(item, '\s\+\S\+\zs')
171+
if match(word, '^\s\+$') > -1
172+
" skip empty words
173+
continue
174+
endif
154175
let column += strdisplaywidth(word, column)
155176
if match(word, "^\\s*\n\\+\\s*$") > -1
156177
call add(result, '')

runtime/doc/cmdline.txt

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
*cmdline.txt* For Vim version 8.2. Last change: 2020 Feb 15
1+
*cmdline.txt* For Vim version 8.2. Last change: 2020 Feb 29
22

33

44
VIM REFERENCE MANUAL by Bram Moolenaar
@@ -476,6 +476,10 @@ emulate it. For example, this mimics autolist=ambiguous:
476476
This will find the longest match with the first 'wildchar', then list all
477477
matching files with the next.
478478

479+
*complete-script-local-functions*
480+
When completing user function names, prepend "s:" to find script-local
481+
functions.
482+
479483
*suffixes*
480484
For file name completion you can use the 'suffixes' option to set a priority
481485
between files with almost the same name. If there are multiple matches,

runtime/doc/eval.txt

Lines changed: 24 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
*eval.txt* For Vim version 8.2. Last change: 2020 Feb 22
1+
*eval.txt* For Vim version 8.2. Last change: 2020 Mar 14
22

33

44
VIM REFERENCE MANUAL by Bram Moolenaar
@@ -4369,6 +4369,8 @@ feedkeys({string} [, {mode}]) *feedkeys()*
43694369
'L' Lowlevel input. Only works for Unix or when using the
43704370
GUI. Keys are used as if they were coming from the
43714371
terminal. Other flags are not used. *E980*
4372+
When a CTRL-C interrupts it sets the internal
4373+
"got_int" flag.
43724374
'i' Insert the string instead of appending (see above).
43734375
'x' Execute commands until typeahead is empty. This is
43744376
similar to using ":normal!". You can call feedkeys()
@@ -5841,6 +5843,15 @@ has({feature}) The result is a Number, which is 1 if the feature {feature} is
58415843
supported, zero otherwise. The {feature} argument is a
58425844
string. See |feature-list| below.
58435845
Also see |exists()|.
5846+
Note that to skip code that has a syntax error when the
5847+
feature is not available, Vim may skip the rest of the line
5848+
and miss a following `endif`. Therfore put the `endif` on a
5849+
separate line: >
5850+
if has('feature')
5851+
let x = this->breaks->without->the->feature
5852+
endif
5853+
< If the `endif` would be in the second line it would not be
5854+
found.
58445855

58455856

58465857
has_key({dict}, {key}) *has_key()*
@@ -8624,7 +8635,12 @@ setpos({expr}, {list})
86248635
setqflist({list} [, {action} [, {what}]]) *setqflist()*
86258636
Create or replace or add to the quickfix list.
86268637

8627-
When {what} is not present, use the items in {list}. Each
8638+
If the optional {what} dictionary argument is supplied, then
8639+
only the items listed in {what} are set. The first {list}
8640+
argument is ignored. See below for the supported items in
8641+
{what}.
8642+
8643+
When {what} is not present, the items in {list} or used. Each
86288644
item must be a dictionary. Non-dictionary items in {list} are
86298645
ignored. Each dictionary item can contain the following
86308646
entries:
@@ -8679,10 +8695,7 @@ setqflist({list} [, {action} [, {what}]]) *setqflist()*
86798695
freed. To add a new quickfix list at the end of the stack,
86808696
set "nr" in {what} to "$".
86818697

8682-
If the optional {what} dictionary argument is supplied, then
8683-
only the items listed in {what} are set. The first {list}
8684-
argument is ignored. The following items can be specified in
8685-
{what}:
8698+
The following items can be specified in dictionary {what}:
86868699
context quickfix list context. See |quickfix-context|
86878700
efm errorformat to use when parsing text from
86888701
"lines". If this is not present, then the
@@ -10498,11 +10511,12 @@ winlayout([{tabnr}]) *winlayout()*
1049810511
" Two horizontally split windows
1049910512
:echo winlayout()
1050010513
['col', [['leaf', 1000], ['leaf', 1001]]]
10501-
" Three horizontally split windows, with two
10502-
" vertically split windows in the middle window
10514+
" The second tab page, with three horizontally split
10515+
" windows, with two vertically split windows in the
10516+
" middle window
1050310517
:echo winlayout(2)
10504-
['col', [['leaf', 1002], ['row', ['leaf', 1003],
10505-
['leaf', 1001]]], ['leaf', 1000]]
10518+
['col', [['leaf', 1002], ['row', [['leaf', 1003],
10519+
['leaf', 1001]]], ['leaf', 1000]]]
1050610520
<
1050710521
Can also be used as a |method|: >
1050810522
GetTabnr()->winlayout()

runtime/doc/helphelp.txt

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
*helphelp.txt* For Vim version 8.2. Last change: 2019 Oct 18
1+
*helphelp.txt* For Vim version 8.2. Last change: 2020 Mar 01
22

33

44
VIM REFERENCE MANUAL by Bram Moolenaar
@@ -368,4 +368,15 @@ highlighting. So do these:
368368

369369
You can find the details in $VIMRUNTIME/syntax/help.vim
370370

371+
*inclusion*
372+
Some people make a big deal about using "his" when referring to the user,
373+
thinking it means we assume the user is male. That is of course not the case,
374+
it's just a habit of writing help text, which quite often is many years old.
375+
Also, a lot of the text is written by contributors for who English is not
376+
their first language. We do not make any assumptions about the gender of the
377+
user, no matter how the text is phrased. And we do not want to waste time on
378+
this discussion. The goal is that the reader understands how Vim works, the
379+
exact wording is secondary.
380+
381+
371382
vim:tw=78:ts=8:noet:ft=help:norl:

runtime/doc/options.txt

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
*options.txt* For Vim version 8.2. Last change: 2020 Feb 14
1+
*options.txt* For Vim version 8.2. Last change: 2020 Mar 02
22

33

44
VIM REFERENCE MANUAL by Bram Moolenaar
@@ -4757,8 +4757,8 @@ A jump table for the options with a short description can be found at |Q_op|.
47574757
be able to execute Normal mode commands.
47584758
This is the opposite of the 'keymap' option, where characters are
47594759
mapped in Insert mode.
4760-
Also consider resetting 'langremap' to avoid 'langmap' applies to
4761-
characters resulting from a mapping.
4760+
Also consider setting 'langremap' to off, to prevent 'langmap' from
4761+
applying to characters resulting from a mapping.
47624762
This option cannot be set from a |modeline| or in the |sandbox|, for
47634763
security reasons.
47644764

@@ -4823,7 +4823,7 @@ A jump table for the options with a short description can be found at |Q_op|.
48234823
'langnoremap' is set to the inverted value, and the other way around.
48244824

48254825
*'langremap'* *'lrm'* *'nolangremap'* *'nolrm'*
4826-
'langremap' 'lrm' boolean (default on, reset in |defaults.vim|)
4826+
'langremap' 'lrm' boolean (default on, set to off in |defaults.vim|)
48274827
global
48284828
{only available when compiled with the |+langmap|
48294829
feature}

runtime/doc/syntax.txt

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
*syntax.txt* For Vim version 8.2. Last change: 2019 Dec 19
1+
*syntax.txt* For Vim version 8.2. Last change: 2020 Feb 29
22

33

44
VIM REFERENCE MANUAL by Bram Moolenaar
@@ -217,7 +217,7 @@ The name for a highlight or syntax group must consist of ASCII letters, digits
217217
and the underscore. As a regexp: "[a-zA-Z0-9_]*". However, Vim does not give
218218
an error when using other characters.
219219

220-
To be able to allow each user to pick his favorite set of colors, there must
220+
To be able to allow each user to pick their favorite set of colors, there must
221221
be preferred names for highlight groups that are common for many languages.
222222
These are the suggested group names (if syntax highlighting works properly
223223
you can see the actual color, except for "Ignore"):
@@ -4512,8 +4512,8 @@ two different ways:
45124512
(e.g., "syntax/pod.vim") the file is searched for in 'runtimepath'.
45134513
All matching files are loaded. Using a relative path is
45144514
recommended, because it allows a user to replace the included file
4515-
with his own version, without replacing the file that does the ":syn
4516-
include".
4515+
with their own version, without replacing the file that does the
4516+
":syn include".
45174517

45184518
*E847*
45194519
The maximum number of includes is 999.

runtime/doc/tags

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5907,6 +5907,7 @@ complete-item-kind insert.txt /*complete-item-kind*
59075907
complete-items insert.txt /*complete-items*
59085908
complete-popup insert.txt /*complete-popup*
59095909
complete-popuphidden insert.txt /*complete-popuphidden*
5910+
complete-script-local-functions cmdline.txt /*complete-script-local-functions*
59105911
complete_CTRL-E insert.txt /*complete_CTRL-E*
59115912
complete_CTRL-Y insert.txt /*complete_CTRL-Y*
59125913
complete_add() eval.txt /*complete_add()*
@@ -7460,6 +7461,7 @@ in_name channel.txt /*in_name*
74607461
in_top channel.txt /*in_top*
74617462
inactive-buffer windows.txt /*inactive-buffer*
74627463
include-search tagsrch.txt /*include-search*
7464+
inclusion helphelp.txt /*inclusion*
74637465
inclusive motion.txt /*inclusive*
74647466
incomp-small-6 version6.txt /*incomp-small-6*
74657467
incompatible-5 version5.txt /*incompatible-5*

runtime/doc/textprop.txt

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
*textprop.txt* For Vim version 8.2. Last change: 2020 Feb 22
1+
*textprop.txt* For Vim version 8.2. Last change: 2020 Mar 05
22

33

44
VIM REFERENCE MANUAL by Bram Moolenaar
@@ -133,8 +133,8 @@ prop_add({lnum}, {col}, {props})
133133
to {lnum}, this is a zero-width text property
134134
bufnr buffer to add the property to; when omitted
135135
the current buffer is used
136-
id user defined ID for the property; when omitted
137-
zero is used
136+
id user defined ID for the property; must be a
137+
number; when omitted zero is used
138138
type name of the text property type
139139
All fields except "type" are optional.
140140

@@ -231,6 +231,7 @@ prop_remove({props} [, {lnum} [, {lnum-end}]])
231231
{props} is a dictionary with these fields:
232232
id remove text properties with this ID
233233
type remove text properties with this type name
234+
both "id" and "type" must both match
234235
bufnr use this buffer instead of the current one
235236
all when TRUE remove all matching text properties,
236237
not just the first one

0 commit comments

Comments
 (0)