Reputation: 3182
The GLSL syntax highlighter http://www.vim.org/scripts/script.php?script_id=1002 works well. But it doesn't recognize .frag or .vert shader files that commonly begin with a line like #version 330
. (This is on Ubuntu 12.04.2 LTS, everything up to date.)
With such a line, after loading the file one must manually type set syntax=glsl
,
probably because /usr/share/vim/vim73/filetype.vim has
" Generic configuration file (check this last, it's just guessing!)
if
... getline(1)=~'^#'
... setf conf
.
Why doesn't that get overruled by ~/.vimrc's au BufNewFile,BufRead *.frag,*.vert setf glsl
? Is there a workaround short of blundering about in filetype.vim?
Upvotes: 2
Views: 809
Reputation: 3182
How can I stop vim from loading a syntax file automatically for certain file types? came close. Here's the workaround, a file ~/.vim/filetype.vim:
if exists("did_load_filetypes")
finish
endif
augroup filetypedetect
" Override filetypes for certain files
autocmd! BufNewFile,BufRead *.frag setfiletype glsl
autocmd! BufNewFile,BufRead *.vert setfiletype glsl
augroup END
Upvotes: 2