New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Vim Syntax: Fix Syntax Error shown on Vim 9.1 #10052
base: master
Are you sure you want to change the base?
Conversation
There occurs a Vim syntax error on a fresh openSUSE Leap 15.5 system when trying to edit the Icinga 2 configuration. The specific packages were vim-9.1.0330-150500.20.12.1.x86_64, vim-icinga2-2.14.2-1.x86_64 and the following error was shown: $ vim -R /etc/icinga2/conf.d/notifications.conf Error detected while processing /usr/share/vim/vim91/suse.vimrc[10]../usr/share/vim/vim91/syntax/syntax.vim[44]..BufRead Autocommands for "/*etc/icinga2/*.conf"..FileType Autocommands for "*"..Syntax Autocommands for "*"..function <SNR>3_SynSet[25]..script /usr/share/vim/site/syntax/icinga2.vim: line 300: E10: \ should be followed by /, ? or & line 301: E10: \ should be followed by /, ? or & line 302: E10: \ should be followed by /, ? or & line 303: E10: \ should be followed by /, ? or & line 304: E10: \ should be followed by /, ? or & line 305: E10: \ should be followed by /, ? or & line 306: E10: \ should be followed by /, ? or & Press ENTER or type command to continue
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So, I did some research as I can't truly believe that a line continuation(\
) is causing a Vim syntax error that has existed for literally decades. But after some testing and messing around with some vim configs, I was actually able to reproduce the exact error shown in the PR description.
First of all, vim
would never be a ‘vim’
😆 if a line continuation would cause a syntax error, and therefore, there must be some other strange things at play to cause such a disaster. Happily, I was able to track down the actual cause of this error, which is that vim only fails with a syntax error due to our syntax highlighting script when started in the OLD GNU vi
compatible mode, which is on
by default. Unfortunately, our highlighting script is not designed to work with vi
, given that vi
does not support syntax highlighting at all, so vim is falling apart badly.
~/Workspace/icinga2 (master ✗) vim -R etc/icinga2/conf.d/services.conf
~/Workspace/icinga2 (master ✗) vim -CR etc/icinga2/conf.d/services.conf
Fehler beim Ausführen von "/Users/yhabteab/.vimrc[1]../opt/homebrew/Cellar/vim/9.1.0350/share/vim/vim91/syntax/syntax.vim[44]..BufRead Autokommandos für "/*etc/icinga2/*.conf"..FileType Autokommandos für "*"..Syntax Autokommandos für "*"..function <SNR>3_SynSet[25]..script /Users/yhabteab/.vim/syntax/icinga2.vim":
Zeile 300:
E10: \ sollte von /, ? oder & gefolgt werden
Zeile 301:
E10: \ sollte von /, ? oder & gefolgt werden
Zeile 302:
E10: \ sollte von /, ? oder & gefolgt werden
Zeile 303:
E10: \ sollte von /, ? oder & gefolgt werden
Zeile 304:
E10: \ sollte von /, ? oder & gefolgt werden
Zeile 305:
E10: \ sollte von /, ? oder & gefolgt werden
Zeile 306:
E10: \ sollte von /, ? oder & gefolgt werden
Betätigen Sie die EINGABETASTE oder geben Sie einen Befehl ein
Given all this, I was wondering why openSUSE doesn't set vim's incompatible mode system-wide in its vimrc file (/usr/share/vim/vim91/suse.vimrc
) by default. Well, it does start vim with incompatible mode, but the flag is not set at the top of the file before anything else as recommended, instead it is set after turning on the syntax highlighting, which inevitably leads to this syntax error.
Thus, I have two possible methods of dealing with that problem. The first and easiest one is to simply create a vimrc
file for the desired user and let vim automatically switch off compatible mode when starting it. The second option is to report the bug to openSUSE and wait for it to be fixed and manually edit the /usr/share/vim/vim91/suse.vimrc
file as a temporary workaround. Nevertheless, I do not expect that we need to change our highlighting script in any way.
That's quite a bit of digging you've done there, thanks! Now it also made sense to my why I first wasn't able to reproduce this behavior on two very different systems with a Vim 9.1.:
As I had a However, in the current state, installing the Footnotes
|
The error does not necessarily depend on the used vim version, but is a pure
There is no syntax highlighting support when using vim with compatible mode and openSUSE also starts vim with incompatible mode, the flag |
Really? I don't think that this is the case and the documentation also doesn't state this. For example, I have just launched Footnotes
|
My mistake, I was just reading this. |
There occurs a Vim syntax error on a fresh openSUSE Leap 15.5 system when trying to edit the Icinga 2 configuration. The specific packages were vim-9.1.0330-150500.20.12.1.x86_64, vim-icinga2-2.14.2-1.x86_64 and the following error was shown:
ref/IP/53301