Disabling syntax highlighting in a specific window in neovim

Viewed 189

I'm having an issue with spell highlighting in my neovim configuration. I'd like spellchecking to be enabled and syntax highlighting to be off when I'm editing markdown and text files, and I can get it to work manually. However, when I try to automate this using ftplugin, the changes don't apply.


In my init.vim, I have

syntax on

Opening any file has intended behavior, syntax highlighting is on.


In ftplugin/markdown.vim, I have:

setlocal formatoptions=1
setlocal linebreak
setlocal spell spelllang=en
setlocal statusline+=\ w:%{WordCount()},
setlocal syntax=off

All other options apply as intended except for syntax options. I know this isn't an issue with spellchecking not working, as I can still see the SpellBad highlighting when setting manually.


Setting setlocal syntax=off manually works fine, I'm just stumped as to why it doesn't apply inside the ftplugin. Any ideas?


system information:

  • nvim v0.4.3
  • Zorin OS 16
1 Answers

if its a filetype plugin, then everything you got in the markdown.vim should be applied only to the filetype markdown, right?

so try this:

set formatoptions=1
set linebreak
set spell spelllang=en
set statusline+=\ w:%{WordCount()},
set syntax=off

i am deducing from your situation (setlocal works manually, but not in ftplugin) that setlocal works only from within vim (as a command). makes sense?

Related