runtime(vim): Update syntax, contain Ex commands#19331
Conversation
f796619 to
7f22036
Compare
|
Can this pr fix this problem? |
5a7def7 to
4c0eba6
Compare
000a492 to
29d0fa6
Compare
29d0fa6 to
9cadc0a
Compare
|
Sorry @mao-yining, I missed your query. Yes, it should fix that issue but that part is still on my machine. I'll update this PR soon. |
80cad4a to
26b6f68
Compare
a6b2138 to
4e08d9a
Compare
8833a2c to
d6714e2
Compare
f059011 to
05dd6de
Compare
| " User Command Highlighting: {{{2 | ||
| " syn match vimUsrCmd '^\s*\zs\u\%(\w*\)\@>\%([<.(#[]\|\s\+\%([-+*/%]\=\|\.\.\)=\)\@!' | ||
| " syn match vimUsrCmd contained '\u\%(\w*\)\@>\%([<.(#[]\|\s\+\%([-+*/%]\=\|\.\.\)=\)\@!' nextgroup=vimBang | ||
| syn match vimUsrCmd contained '\%#=1\<\u\w\+\>\%([![:space:]]\|$\)\@=' nextgroup=vimBang |
There was a problem hiding this comment.
\u\w\+will match invalid patterns like:My_Invalid_Command. It needs to be[:alnum:].- It would be easier to read with very magic to reduce the
\overload. - POSIX character classes throughout would be better too.
- Characters (like vertical tab and line-end) in
[:space:], if used after a command, give errors. A tab or space only is allowed, so[:blank:]should replace[:space:]:
syn match vimUsrCmd contained '\v<[[:upper:]][[:alnum:]]+>%([[:blank:]!]|$)@=' nextgroup=vimBang
Illustrating with /\v<[[:upper:]][[:alnum:]]+>%([[:space:]!]|$)@= why it should be [:blank:]:
There was a problem hiding this comment.
\u\w\+will match invalid patterns like:My_Invalid_Command. It needs to be[:alnum:].
Fixed.
- It would be easier to read with very magic to reduce the
\overload.
I don't want to mix pattern styles. The default is used by about 95% of the syntax files and also gets some useful highlighting.
"Easier to read" also depends on what you've been reading and for how long. :)
- POSIX character classes throughout would be better too.
For aesthetics? The \u atoms are faster.
- Characters (like vertical tab and line-end) in
[:space:], if used after a command, give errors. A tab or space only is allowed, so[:blank:]should replace[:space:]:
They're interchangeable in this syntax file, if you allow for the invalid syntax, and in this case it catches the pathological ^@ case. I'll update the use of [:space:] to [:blank:] throughout the file in a different commit in the interests of correctness.
I expect the pattern can be simplified further to something more like \u[[:alnum:]]*\%([^[:alnum:]]\|$\)\@=. It's impossible to match perfectly without the actual user command list, we can only hope for tasteful use of whitespace.
syn match vimUsrCmd contained '\v<[[:upper:]][[:alnum:]]+>%([[:blank:]!]|$)@=' nextgroup=vimBangIllustrating with
/\v<[[:upper:]][[:alnum:]]+>%([[:space:]!]|$)@=why it should be[:blank:]:
They're all valid matches for a user command as far as I'm concerned. We don't try to invalidate earlier matches or entire commands based on later syntax errors.
The last match should be valid and is executed as
MyHelp
vim9cmd
d960e6c to
2b889f9
Compare
0fe3893 to
58fa350
Compare
- Contain Ex commands to valid syntactic contexts. - Add full address (:range) matching. - Match :Next, :Print, :X, :&, :~, :>, :<, :# and := commands. - Full matching of :global and :append (with folding) commands. For improved performance, use :syn-keyword to match all commands except when immediately following \w range characters where :syn-match is used. Fixes: - vim#20250 (variables with s_ prefix are wrongly highlighted) - vim#17543 (do not highlight vim commands within :runtime) - vim#16937 (do not highlight vim commands after packadd) - vim#14895 (incorrect highlighting of Vim syntax) - vim#14020 (insert commands) Signed-off-by: Doug Kearns <dougkearns@gmail.com>
58fa350 to
b9eb3a5
Compare
Fixes:
s_prefix are wrongly highlighted #20250