Hacktoberfest 2026: le issue che i maintainer hanno segnato per ottobre, aperte e adatte ai principianti. Sfoglia le issue Hacktoberfest

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

Aperta
#198 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
3/5
Tempo stimato
1-2 giorni
Idoneità per principianti
35/100
Tipo di issue
Bug
Chiarezza
Abbastanza chiara
Stato di attività
Ferma
Stack tecnologico
vim
Ambito
tooling

Direzione di ricerca

Start by reproducing the error with the attached timetracker.txt renamed to timetracker.vim, focusing on the errTimestamp syntax line and the parser entry point used for it. Compare the parser's handling of the long regular expression with Vim's successful parsing, then add a regression case that parses the line without reporting E492.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

I had originally posted this error on the vim-language-server issue, and the author of that projected directed me to vim-vmlparser. Here's my original post:

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):

  • OS: macOS Monterey 12.6.3
  • vim 9.0.1-1400 (installed via Homebrew)
VIM - Vi IMproved 9.0 (2022 Jun 28, compiled Mar 11 2023 13:55:53)
macOS version - x86_64
Included patches: 1-1400
Compiled by Homebrew
Huge version without GUI.  Features included (+) or not (-):
+acl               +file_in_path      +mouse_urxvt       -tag_any_white
+arabic            +find_in_path      +mouse_xterm       -tcl
+autocmd           +float             +multi_byte        +termguicolors
+autochdir         +folding           +multi_lang        +terminal
-autoservername    -footer            -mzscheme          +terminfo
-balloon_eval      +fork()            +netbeans_intg     +termresponse
+balloon_eval_term +gettext           +num64             +textobjects
-browse            -hangul_input      +packages          +textprop
++builtin_terms    +iconv             +path_extra        +timers
+byte_offset       +insert_expand     +perl              +title
+channel           +ipv6              +persistent_undo   -toolbar
+cindent           +job               +popupwin          +user_commands
-clientserver      +jumplist          +postscript        +vartabs
+clipboard         +keymap            +printer           +vertsplit
+cmdline_compl     +lambda            +profile           +vim9script
+cmdline_hist      +langmap           -python            +viminfo
+cmdline_info      +libcall           +python3           +virtualedit
+comments          +linebreak         +quickfix          +visual
+conceal           +lispindent        +reltime           +visualextra
+cryptv            +listcmds          +rightleft         +vreplace
+cscope            +localmap          +ruby              +wildignore
+cursorbind        +lua               +scrollbind        +wildmenu
+cursorshape       +menu              +signs             +windows
+dialog_con        +mksession         +smartindent       +writebackup
+diff              +modify_fname      +sodium            -X11
+digraphs          +mouse             +sound             -xfontset
-dnd               -mouseshape        +spell             -xim
-ebcdic            +mouse_dec         +startuptime       -xpm
+emacs_tags        -mouse_gpm         +statusline        -xsmp
+eval              -mouse_jsbterm     -sun_workshop      -xterm_clipboard
+ex_extra          +mouse_netterm     +syntax            -xterm_save
+extra_search      +mouse_sgr         +tag_binary
-farsi             -mouse_sysmouse    -tag_old_static
  system vimrc file: "$VIM/vimrc"
    user vimrc file: "$HOME/.vimrc"
2nd user vimrc file: "~/.vim/vimrc"
     user exrc file: "$HOME/.exrc"
      defaults file: "$VIMRUNTIME/defaults.vim"
 fall-back for $VIM: "/Users/tblancher/homebrew/share/vim"
Compilation: clang -c -I. -Iproto -DHAVE_CONFIG_H -DMACOS_X -DMACOS_X_DARWIN -g -O2 -D_REENTRANT -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=1
Linking: clang -L/usr/local/lib -o vim -lm -lncurses -lsodium -liconv -lintl -framework AppKit -L/Users/tblancher/homebrew/opt/lua/lib -llua5.4 -mmacosx-version-min=11.7 -fstack-protector-strong -L/usr/local/lib -L/Users/tblancher/homebrew/opt/perl/lib/perl5/5.36/darwin-thread-multi-2level/CORE -lperl -L/Users/tblancher/homebrew/opt/[email protected]/Frameworks/Python.framework/Versions/3.11/lib/python3.11/config-3.11-darwin -lpython3.11 -lintl -framework CoreFoundation -lruby.3.2 -L/Users/tblancher/homebrew/Cellar/ruby/3.2.1/lib
  • vim-language-server (re-)installed today, vim-lsp uses npm for this
  • vim-lsp installed via vim-plug

Log:

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

Lingua principale
Vim Script
Stelle
173
Fork
28
Metriche di merge delle PR
Nessuna PR unita negli ultimi 30g

Preparare l'ambiente

Non abbiamo ancora controllato i file di configurazione di questo progetto. Parti dal suo README e consulta la nostra guida al primo contributo per i passaggi generali.

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di vim-jp/vim-vimlparser

Tutte le issue di vim-jp/vim-vimlparser

Issue simili

Altre issue su DevTools

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.