Use gotags + tagbar in vim-go without Exuberant Ctags installed

822 views
Skip to first unread message

mura

unread,
Mar 17, 2016, 11:57:08 AM3/17/16
to golang-nuts
Here is a tip:

1. Create a shell script named "gotags-for-tagbar.sh" as follows, and put it into one of your search paths $PATH (or alongside gotags executable)


#!/bin/sh

if [ "$1" = "--version" ]; then

       echo Universal Ctags

       exit 0

fi


gotags "$@"



2. In .vimrc, add the following line:


let g:tagbar_ctags_bin='gotags-for-tagbar.sh'


It works for me.



Quincy Bowers

unread,
Mar 18, 2016, 11:06:13 AM3/18/16
to golang-nuts

You can also set something like this in your .vimrc and then you don't need to create a separate script.
 
 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'
\ }


Reply all
Reply to author
Forward
0 new messages