iamcco / vim-language-server

VImScript language server, LSP for vim script
508 stars 17 forks source link

E492: Not an editor command: when parsing a long regular expression #87

Closed trey-pindrop closed 1 year ago

trey-pindrop commented 1 year ago

Describe the bug I'm not sure why this error is being thrown, it seems to be throwing an error at a specific point and I don't understand why. I have a long regex pattern which is designed to match a timestamp string (%Y-%m-%d %H:%M:%S), and a negation to flag invalid timestamps as errors. The syntax line in question:

syntax region errTimestamp     matchgroup=timestamp start="^\%(\d\{4}-\%(0[135789]-\%([0-2]\d\|3[01]\)\|\%(1[02]-\%([0-2]\d\|3[01]\)\)\|0[46]-\%([0-2]\d\|30\)\|11-\%([0-2]\d\|30\)\|02-[0-2]\d\) \%([01]\d\|2[0-3]\)\%(:[0-5]\d\)\{2}\)\@!"         end=":  "  

It generates the following error:

E492: Not an editor command: [0-3]\)\%(:[0-5]\d\)\{2}\)\@!"         end=":  "  

I have vim-language-parser installed using vim-lsp (which itself is installed via vim-plug)

Here's a screenshot of the error: Screen Shot 2023-04-07 at 16 05 06

Here's the full copy of my syntax file:
timetracker.txt

Here's an example log file the syntax file highlights: example.log

This file loads successfully, vim doesn't make a similar complaint when applying the syntax highlighting to my log file.

To Reproduce Steps to reproduce the behavior:

  1. Rename timetracker.txt to timetracker.vim, and ensure vim-language-server parses the file
  2. On errTimestamp line, vim-language-server throws an error.

At first I thought it might be too many capture groups, but I replaced all the nested \(...\) with \%(...\). An interesting thing about this, the character it highlights is the last character of the visual line before it line wraps, or the last visible character of the line with :set nowrap set.

Expected behavior I don't expect vim to show an error on this line, not when vim itself can parse this line correctly (and not throw an error).

Screenshots If applicable, add screenshots to help explain your problem.

Desktop (please complete the following information):

Log:

Not sure how to capture logs from vim-language-server. enabling logging in vim-lsp doesn't appear to log the error.

iamcco commented 1 year ago

Bug of viml-parser

trey-pindrop commented 1 year ago

OK, I'll try to follow up on that repo/project.

trey-pindrop commented 1 year ago

@iamcco Do you have a link to the viml-parser project? Searching GitHub looks like it finds a few results.

iamcco commented 1 year ago

@iamcco Do you have a link to the viml-parser project? Searching GitHub looks like it finds a few results.

https://github.com/vim-jp/vim-vimlparser

trey-pindrop commented 1 year ago

I posted this issue to the vim-vimlparser issue. Thanks for directing me there. I'll go ahead and close this.