配置 ctags 以在 Go 源文件中显示导入项。

huangapple go评论72阅读模式
英文:

Configure ctags to show also the imports in go source file

问题

我正在使用exeburent-ctags来为我的Go源文件进行标记。默认情况下,ctags不会显示我的Go文件中的导入语句。如何配置ctags以在文件中显示导入语句。我正在使用Linux上的最新版本ctags。因此,它默认支持Go语言。我需要覆盖ctags的配置。

英文:

I'm using exeburent-ctags for tagging my go source files. By default ctags is not showing import statements in my go files. How to configure ctags to display also the import statements in the file.
I'm using latest version of ctags in linux. So it has default support for go lang. I need to override the ctags configuration.

答案1

得分: 3

首先,我建议使用支持gocode的编辑器(例如SublimeText + Gosublime,Atom + go-plus,vim + vim-go等)。

如果你真的想要使用ctags,可以查看gotags

英文:

First, I recommend using an editor that supports gocode (SublimeText + Gosublime, Atom + go-plus, vim + vim-go to name a few).

If you really want ctags, check gotags.

答案2

得分: 0

Go版本1.1或更高版本是必需的。使用go get命令安装或更新gotags:

go get -u github.com/jstemmer/gotags

或者

brew install gotags

生成标签的命令是:

gotags -R *.go >> tags

你必须使用支持catgs的编辑器,我个人使用vim+tagbar。

这是我在.vimrc中使用的tagbar配置:

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'
}

配置 ctags 以在 Go 源文件中显示导入项。

英文:

Go version 1.1 or higher is required. Install or update gotags using the go get command:

go get -u github.com/jstemmer/gotags  

or

brew install gotags  

the commands for generating tags is :

gotags -R *.go >> tags  

you have to use an editor that support catgs personnaly i use vim+tagbar

and there is the configuration that i use for tagbar in my .vimrc :

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'
\ }

配置 ctags 以在 Go 源文件中显示导入项。

huangapple
  • 本文由 发表于 2015年8月20日 13:45:03
  • 转载请务必保留本文链接:https://go.coder-hub.com/32110397.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定