Search code examples
vimsyntaxhighlighting

Why can't I change vim syntax highlighting via local vimrc file?


I am trying to customize vim highlighting by placing additional instructions into local config $project/.lvimrc, which is managed by the https://github.com/embear/vim-localvimrc plugin.

Unfortunately, it seems that commands like

syntax match Operator "\<MYOP\>"

located in .lvimrc are ignored silently by vim. Typing the command in the command line works as expected. Other commands from .lvimrc also work. So what may stop vim from interpreting local highlighting correctly?


Solution

  • That was because https://github.com/embear/vim-localvimrc plugin launches local files in a sandbox by default. Syntax commands are not allowed in a sandbox (at least in my setup), so the exception was raised. For some reason, Vim handles such exceptions silently.

    In my case, the following modifications formed a solution:

    1. Disable sandboxes for localvimrc by adding let g:localvimrc_sandbox = 0 to master .vimrc file
    2. Add set conceallevel=2 to the localvimrc