I'm working on a todo plugin for Neovim, using the remote plugin API.

I set highlight groups and matching patterns in my script, and then register it with call remote#host#RegisterPlugin. When Neovim starts, everything works well, and all matching patterns/highlight groups are displayed correctly.

Highlight groups

However, after I source my init.vim (no matter if I actually change anything or not), everything disappears: FIXME and TODO return to their default highlight group (not sure if it's being set by Vim or by my theme, see pic. 2)


I thought that during applying the config, my highlight groups and/or matching patterns get deleted, but echo getmatches() and echo highlight_exists("%MY_GROUP_NAME%") show that they're still there, but are inactive for some reason:

-> echo getmatches()
<- [{'group': 'TS_TODO_GROUP_TODO', 'pattern': '@TODO', 'priority': 0, 'id': 4}, {'group': 'TS_TODO_GROUP_BUG', 'pattern': '@BUG', 'priority': 0, 'id':
 5}, ... {'group': 'Space', 'pattern': '\s', 'priority': 10, 'id': 1}]

-> echo highlight_exists("TS_TODO_GROUP_BUG")
<- 1

Reapplying the same groups/patterns via the remote plugin (I registered a command that calls the same init function that gets called during Vim startup) makes no effect. WAIDW?

  • Managed to "fix" that with a hack, by adding a SourcePost autocmd with $MYVIMRC as a pattern. Then it calls init() in my script and everything seems to be working again. Is there a less hacky way to do this?
    – F'1
    Apr 25, 2021 at 7:01
  • 1
    I have a remap to re-source my syntax highlighting (it occasionally gets messed up - I think due to some interaction with folding): nnoremap <F12> :syntax sync fromstart<cr>. Maybe that command can help you.
    – mattb
    Apr 25, 2021 at 12:42
  • 2
    Welcome to Vi and Vim!
    – D. Ben Knoble
    Apr 25, 2021 at 13:52


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.