My conceal options are not loading in vim

515 views Asked by At

I have some conceal options (syntax match Normal '\.md\]' conceal cchar=]) added in a $HOME/.vim/after/syntax/base.vim.

They are not loaded when I open a file. But if i do :source $HOME/.vim/after/syntax/base.vim the conceal is activated.

In .vimrc I have also this:

syntax on
set conceallevel=2

I even tried with this options in my .vimrc

source ~/.vim/after/syntax/base.vim
let g:mysyntaxfile = '~/.vim/after/syntax/base.vim'
au VimEnter,BufEnter source ~/.vim/after/syntax/base.vim

Nothing works. Only source from vim Command Mode.

2

There are 2 answers

0
Samar On

base.vim should have been markdown.vim. Now it works.

0
romainl On

When they are not sourced explicitly, with something like source /path/to/foo.vim or runtime foo.vim, syntax scripts are sourced automatically on a per-filetype basis. Basically…

  1. :e foo.js creates a buffer for that file,
  2. Vim picks up that it is a JavaScript file so it assigns the javascript filetype and the javascript syntax,
  3. Vim sources all the */syntax/javascript.vim scripts it can find in $RUNTIMEPATH.

Conclusion: if you want to source a specific syntax script for a specific filetype, name it appropriately:

<filetype>.vim