Likely the quick fix:
- make sure syntax is on at all
- increase synmaxcol
- increase maxmempattern
syntax on
set synmaxcol=5000
set maxmempattern=5000To elaborate
I was writing the code for a custom cursor for this blog, when suddenly my (S)CSS file would not have any more syntax highlighting. I was using neovim with a bunch of plugins installed.
Syntax highlighting was disabled as soon as I inserted a specific line, that was a lot longer than any other line.
Turning it back on again using syntax on did not yield any results.
Through a quick search I found out there is this variable in (neo)vim called
synmaxcol,
which sets the maximum number of cols after which syntax highlighting is no longer applied.
Note that this only affects this specific line.
The current value of this variable can be echoed with this command (see the bottom of the terminal window):
set synmaxcol?
In my case, syntax highlighting was disabled for the whole file.
Also the line was much shorter than the value of synmaxcol.
I tried to activate syntax highlighting again and to my surprise this time neovim communicated the problem:
The maxmempattern value was too low for that file.
So, if you have issues with syntax highlighting not working, try increasing maxmempattern.
The error message might just be hiding behind lots of plugin stuff.