配置VIM go开发环境

1. 函数,结构体跳转:

在~/.ctags 里加入:

--langdef=Go

--langmap=Go:.go

--regex-Go=/func([ \t]+\([^)]+\))?[ \t]+([a-zA-Z0-9_]+)/\2/d,func/

--regex-Go=/var[ \t]+([a-zA-Z_][a-zA-Z0-9_]+)/\1/d,var/

--regex-Go=/type[ \t]+([a-zA-Z_][a-zA-Z0-9_]+)/\1/d,type/

2. 安装VIM插件tagbar http://www.vim.org/scripts/script.php?script_id=3465

 vim tagbar.vba 

 :so % 

 :q 

 配置VIM,在~/.vimrc中加入

 let g:tagbar_ctags_bin=/usr/local/bin/ctags

 let g:tagbar_width=30

 map <F8> :TagbarToggle<CR>

3. 至此,tagbar还是显示不了文件中的函数,结构体定义等,需要配合gotags

    配置GOPATH,后安装gotags

go get -u github.com/jstemmer/gotags

4. 配置VIM

let g:tagbar_type_go = {

    \ 'ctagstype' : 'go',

    \ 'kinds'     : [

        \ 'p:package',

        \ 'i:imports:1',

        \ 'c:constants',

        \ 'v:variables',

        \ 't:types',

        \ 'n:interfaces',

        \ 'w:fields',

        \ 'e:embedded',

        \ 'm:methods',

        \ 'r:constructor',

        \ 'f:functions'

    \ ],

    \ 'sro' : '.',

    \ 'kind2scope' : {

        \ 't' : 'ctype',

        \ 'n' : 'ntype'

    \ },

    \ 'scope2kind' : {

        \ 'ctype' : 't',

        \ 'ntype' : 'n'

    \ },

    \ 'ctagsbin'  : 'gotags',

    \ 'ctagsargs' : '-sort -silent'

\ }

5. OK。

 

你可能感兴趣的:(开发环境)