开发者

How to enable go.vim by default (automatically)?

The instructions on the Vim site says to just put the file in the /syntax folder. This works all right and well. But, for me to use the syntax I must set the following

:set syntax=go

Every single time. So, I know I am doing something wrong. I just don't know what.

Here are some things from looking around,

My HTML5 syntax set is from Rodrigo's HTML5 omnicomplete function and syntax vimball file. Though this uses some installation script to get it going.

As far as I can tell this would be my first manual adding of syntax file.

Also, my VIMRUNTIME is not set, well because there is no syntax.vim file, so from reading the documentation I see it checks for files via synload.vim

I even read the "Making Your Own Syntax Files" section, which says that same as above with the syntax=go option. Am I supposed to be detecting the .go filetype as described in new filetype section?

How can I enable syntax highlighting for GO by default?

This is for Mac Snow Leopard.

I don't think it is this complicated but I 开发者_开发知识库decided to leave all the different documentation I skimmed. GO and Vim say to just add the file. But it is definitely not detecting it automatically


If you are using filetype detection in your ~/.vimrc file with the following line:

filetype plugin indent on

then you can place the file in the following folder:

~/.vim/after/ftplugin/go.vim

or for windows

~/vimfiles/...

For the filetype detection to work, would would want the autocmd in a file in the ftdetect folder:

~/.vim/ftdetect/go.vim

and the contents would be:

autocmd BufNewFile,BufReadPost *.go set filetype=go


Use autocmd:
au BufRead,BufNewFile *.go setlocal filetype=go

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜