I've a project where I work on OpenGL Shaders.
I downloaded the glsl syntax file and installed it on my computer (a personal folder) and then added the following auto-load line to my .vimrc
:
au BufNewFile,BufReadPost *.shader,*.frag,*.vert,*.fp,*.vp,*.glsl so $HOME/vim/glsl.vim
When I first load one of my '*.shader' file, I get the syntax highlighting as expect. The second time (i.e. say I loaded two files, I do :n
and then :N
), the highlighting is non-existent.
The syntax variable is properly set, syntax=glsl
, but the text is just plain black on white.
The glsl.vim
file has just two things that could cause a problem:
" near the start
if exists("b:current_syntax") && b:current_syntax == "glsl"
finish
endif
...
" near the end
if !exists("b:current_syntax")
let b:current_syntax = "glsl"
endif
I tried to remove the && b:current_syntax == "glsl"
, because other syntax files do not have that. No difference.
Then I tried to remove the if !exists("b:current_syntax")
near the end, and again, no difference.
All my other syntax files work as expected, so I'm not too sure why this one would have such a problem. Everything get colors (my .h and .cpp files, CMakeLists.txt, .sh, etc.) except those *.shader
files outside of the first load.