Similar to "sh.vim", there are a handful of other filetypes
whose names (assigned to "b:current_syntax") are different
from the base names of their syntax plugins, e.g. "python2"
and "elsa". Two scripts, "testdir/tools/maketestdeps" and
"testdir/runtest.vim", currently assume that the base name
of a syntax plugin can be derived from the name of a syntax
test. Prescribe using the base name of the syntax plugin,
instead of its filetype, for a test filename prefix so that
existing files are listed in Make targets ("maketestdeps")
and name correspondence is kept between the syntax plugin
and optional test settings for it ("runtest.vim"). Add a CI
check for name verification.
closes: #21414
Signed-off-by: Aliaksei Budavei <0x000c70@gmail.com>
Signed-off-by: Christian Brabandt <cb@256bit.org>
Test-case filenames should always begin with the associated
filetype name, properly delimited from the remaining part of
the filename. As of v9.2.0636~1, a convenience function
"DeferRenamingTestFileTo" is provided in "VIM_TEST_SETUP"
aware contexts to temporarily give the file under test
another, arbitrary name before executing ":syntax on".
closes: #21352
Signed-off-by: Aliaksei Budavei <0x000c70@gmail.com>
Signed-off-by: Christian Brabandt <cb@256bit.org>
Problem: [security]: code injection via rmd syntax pattern for fenced
languages (ylerni7-ant)
Solution: Keep only the leading word characters of the language name
in the syntax script.
Github Security Advisory:
https://github.com/vim/vim/security/advisories/GHSA-x2w5-pj55-7hpc
Assisted-by: Claude Opus
Signed-off-by: Christian Brabandt <cb@256bit.org>
Problem: the image feature can be improved
Solution: Refactor the image feature, make use of the pixman library if
possible, add image_info(), image_add() and image_discard()
functions and the 'imageprotocol' option (Foxe Chen)
closes: #21234
Assisted-by: Claude
Signed-off-by: Foxe Chen <chen.foxe@gmail.com>
Signed-off-by: Christian Brabandt <cb@256bit.org>
Problem: There is no way to get the definition of a builtin or a user
defined function, of an Ex command, of an option or of a v:
variable from Vim script. A language server has to parse the
help text or the output of ":function" and ":command" for it.
Solution: Add getinfo({kind}, {name} [, {opts}]), which returns a Dict
with the definition of {name}: a function, an Ex command, an
option or a v: variable. Keep the names of the arguments of
the builtin functions in their table and report them in
"args" (Hirohito Higashi).
closes: #21293
Assisted-by: Claude
Signed-off-by: Hirohito Higashi <h.east.727@gmail.com>
Signed-off-by: Christian Brabandt <cb@256bit.org>
Problem: The paren-based typescriptArrowFuncDef patterns contain a nested
quantifier, \%(\_[^()]\+\|...\)*, which backtracks exponentially
with the old regexp engine when the match fails.
Solution: Drop the inner \+; the matched language is unchanged.
closes: #21400
related: HerringtonDarkholme/yats.vim#306
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: Miura Yasuyuki <kokosabu@gmail.com>
Signed-off-by: Christian Brabandt <cb@256bit.org>
- Terminate :global patterns, and :substitute patterns and replacement
text, at EOL. The closing delimiter is optional.
- Clarify the behaviour of optional pattern terminators in the :global
and :substitute help sections.
related: #21132
closes: #21367
Signed-off-by: Doug Kearns <dougkearns@gmail.com>
Signed-off-by: Christian Brabandt <cb@256bit.org>
Problem: filetype: icalendar files are not recognized
Solution: Detect *.ics files as icalendar filetype, include
syntax and filetype plugins (Anakin Childerhose).
Reference:
https://datatracker.ietf.org/doc/html/rfc5545closes: #21356
Assisted-By: Claude Opus 5
Signed-off-by: Anakin Childerhose <anakin@childerhose.ca>
Signed-off-by: Christian Brabandt <cb@256bit.org>
Whenever two or more filetype names share a common prefix,
e.g. "java" and "javascript", passing the shortest name
argument to Make, e.g. "make java test", will trigger the
running of _all prefix matching_ test suites. To fix this
blunder and to only have _requested_ test suites run, always
append the leftmost conventional delimiters "[._]", e.g.
"java[.]java", "java[_]numbers.java", to each filetype name
when automatically assembling a regexp pattern for the
filename filter. Furthermore, promote the Vim9 (pseudo-)
filetype, e.g. "make vim9 test", "make vim vim9 test", etc.
As before, VIM_SYNTAX_TEST_FILTER is still within reach for
arbitrary test case grouping.
closes: #21351
Signed-off-by: Aliaksei Budavei <0x000c70@gmail.com>
Signed-off-by: Christian Brabandt <cb@256bit.org>
- Prefer non-capturing groups in patterns - idiomatic.
- Remove changelog entries - there is no maintainer to inform.
- Normalise whitespace use.
closes: #21348
Signed-off-by: Doug Kearns <dougkearns@gmail.com>
Signed-off-by: Christian Brabandt <cb@256bit.org>
Fix potentially catastrophic backtracking in number patterns when using
regexpengine=1.
closes: #21324
Signed-off-by: Doug Kearns <dougkearns@gmail.com>
Signed-off-by: Christian Brabandt <cb@256bit.org>
Problem: Highlighting nginx.conf is slow; the ngxSSLCipherInsecure group
alone accounts for ~39% of the total syntax parse time because it
is spread over ~34 separate non-contained :syn match rules that are
each scanned at every position of every line.
Solution: Merge the ~28 rules sharing the identical '[^!]\zs' prefix into a
single alternation match, keeping only the six rules that need a
different preceding-character constraint separate. Highlighting is
unchanged; total syntax parse time drops by ~42% on a large config.
Update the Date header to Vims preferred format.
closes: #21195
Signed-off-by: Julien Voisin <julien.voisin@dustri.org>
Signed-off-by: Christian Brabandt <cb@256bit.org>
Fix matching of the pattern arg in a :syn-sync-match skip command.
closes: #21289
Signed-off-by: Doug Kearns <dougkearns@gmail.com>
Signed-off-by: Christian Brabandt <cb@256bit.org>
Problem: recursion error when setting ft=syntax
Solution: Skip the special syntax filetype
(Christoffer Aasted)
This:
vim -Nu NONE \
+'set filetype=syntax' \
+'syntax on'
yields
E127: Cannot redefine function <SNR>2_SynSet: It is in use
Setting filetype=syntax will try to reload synload.vim while SynSet() is
still executing which causes this error.
closes: #21271
Signed-off-by: Christoffer Aasted <dezzadk@gmail.com>
Signed-off-by: Christian Brabandt <cb@256bit.org>
Similar to markdown syntax, by default do not highlight raw and code blocks.
Syntax highlighting groups are still in place so it is possible for
users to add their own if needed.
- typstMarkupRawInline
- typstMarkupRawBlock
closes: #21260
Signed-off-by: Maxim Kim <habamax@gmail.com>
Signed-off-by: Christian Brabandt <cb@256bit.org>
Problem: Spup syntax fails for an out-of-range comment mode.
Solution: Add the missing let to the fallback assignment (Qiming zhao).
Setting oneline_comments above 3 raises E492 while loading the syntax
script. Use a valid legacy Vim script assignment to restore the default
value of 2.
Validated with oneline_comments set to 1, 2, 3, 4 and 99, and with the
variable unset. The original script fails with E492 for a value of 4.
The corrected script loads and applies the expected comment mode.
closes: #21227
Supported by AI.
Signed-off-by: Qiming zhao <chemzqm@gmail.com>
Signed-off-by: Christian Brabandt <cb@256bit.org>
Problem: The floating-point `.d` number match and the two ellipsis
matches are slow: each begins with a look-behind, which cannot
be reduced to a fixed first character, so the automatic regexp
engine selects the slower NFA backend for them.
Solution: Force the backtracking engine with \%#=1 on those three
patterns; it evaluates the look-behind far more efficiently.
Highlighting is unchanged.
Measured with :syntime over a 40000 line corpus: the three affected
rules drop from ~0.13s to ~0.008s (about -93%), which cuts the total
syntax parse cost by ~10% (1.85s to 1.65s).
closes: #21194
Signed-off-by: Julien Voisin <julien.voisin@dustri.org>
Signed-off-by: Christian Brabandt <cb@256bit.org>
Problem: C keywords are matched using the characters from 'iskeyword',
so changing that option highlights part of an identifier as a
keyword and leaves keywords containing an underscore
unhighlighted.
Solution: Set the keyword characters with ":syn iskeyword".
fixes: #21173closes: #21176
Co-Authored-By: Maxim Kim <habamax@gmail.com>
Signed-off-by: Hirohito Higashi <h.east.727@gmail.com>
Signed-off-by: Christian Brabandt <cb@256bit.org>
Problem: YAML syntax highlighting is slow; the yamlInteger and yamlFloat
rules alone account for over half of the parsing time.
Solution: The number, null and timestamp scalar patterns begin with a
lookbehind, which stops the regexp engine from using a
first-character search, so the automatic engine selects the
much slower NFA engine. Force the backtracking engine with
\%#=1 on these patterns for a large speedup with identical
matches (Jordan).
On a 40000-line YAML file the total :syntime drops by about 30%: the
yamlFloat rule goes from 0.61s to 0.17s and yamlInteger from 0.42s to 0.31s.
The engine override is applied only to the lookbehind-anchored number rules;
forcing it on the structural plain-scalar and mapping-key patterns regresses
them badly, so those are left on the automatic engine.
closes: #21182
Signed-off-by: Julien Voisin <julien.voisin@dustri.org>
Signed-off-by: Christian Brabandt <cb@256bit.org>
- Contain all matches to a single line.
- Define non-extending groups for the command-line window.
- Replace &buftype-based detection with win_gettype().
closes: #21189
Signed-off-by: Doug Kearns <dougkearns@gmail.com>
Signed-off-by: Christian Brabandt <cb@256bit.org>
Problem: Several tag and attribute names are highlighted with regular
expression alternations even though they are plain words. A
:syn-match with an alternation is retried at nearly every
position of every tag.
Solution: Move the plain-word tag names (b, i, u, em, strong, head,
body, title, h1-h6) and the "label", "href" and "title"
attribute names into syn-keyword lists, leaving only the
genuinely hyphenated names "accept-charset" and "http-equiv"
as matches.
Profiling a 6000-line HTML file with :syntime, the converted rules drop
from a combined 0.044s to 0.004s, lowering total per-rule syntax time
by about 15%. Highlighting is unchanged except that a bare valueless
"href" attribute is now highlighted as an attribute, consistent with a
bare "title", which already behaved that way.
closes: #21155
Signed-off-by: Julien Voisin <julien.voisin@dustri.org>
Signed-off-by: Doug Kearns <dougkearns@gmail.com>
Signed-off-by: Christian Brabandt <cb@256bit.org>
Hi-link a few more straggler pattern groups to Regexp.
closes: #21165
Signed-off-by: Doug Kearns <dougkearns@gmail.com>
Signed-off-by: Christian Brabandt <cb@256bit.org>