Álvaro Ramírez
04 June 2019 gnu global, ctags, and Emacs setup
Universal ctags (newer)
I'm now using universal ctags, as recommended by counsel-etags.
From universal ctag's Building on Mac OS:
brew tap universal-ctags/universal-ctags brew install --HEAD universal-ctags
.ctags
--langdef=swift --langmap=swift:+.swift --kinddef-swift=v,variable,variables --kinddef-swift=f,function,functions --kinddef-swift=s,struct,structs --kinddef-swift=c,class,classes --kinddef-swift=p,protocol,protocols --kinddef-swift=e,enum,enums --kinddef-swift=t,typealias,typealiases --regex-swift=/(var|let)[ \t]+([^:=]+).*$/\2/v/ --regex-swift=/func[ \t]+([^\(\)]+)\([^\(\)]*\)/\1/f/ --regex-swift=/struct[ \t]+([^:\{]+).*$/\1/s/ --regex-swift=/class[ \t]+([^:\{]+).*$/\1/c/ --regex-swift=/protocol[ \t]+([^:\{]+).*$/\1/p/ --regex-swift=/enum[ \t]+([^:\{]+).*$/\1/e/ --regex-swift=/(typealias)[ \t]+([^:=]+).*$/\2/v/
Exuberant ctags (older/buggy?)
Install gnu global (ensure homebrew uses –with-exuberant-ctags flag).
brew install global brew install ctags pip install pygments
.ctags
--langdef=swift --langmap=swift:.swift --regex-swift=/[[:<:]]class[[:>:]][[:space:]]+([[:alnum:]_]+)/\1/c,class/ --regex-swift=/[[:<:]]enum[[:>:]][[:space:]]+([[:alnum:]_]+)/\1/e,enum/ --regex-swift=/[[:<:]]func[[:>:]][[:space:]]+([[:alnum:]_]+)/\1/f,function/ --regex-swift=/[[:<:]]protocol[[:>:]][[:space:]]+([[:alnum:]_]+)/\1/P,protocol/ --regex-swift=/[[:<:]]struct[[:>:]][[:space:]]+([[:alnum:]_]+)/\1/s,struct/ --regex-swift=/[[:<:]]typealias[[:>:]][[:space:]]+([[:alnum:]_]+)/\1/t,typealias/
.globalrc
default:\ :tc=pygments: ctags:\ :tc=exuberant-ctags: exuberant-ctags|plugin-example|setting to use Exuberant Ctags plug-in parser:\ :tc=common:\ :ctagscom=ctags:\ :ctagslib=$libdir/gtags/exuberant-ctags.la:\ :langmap=Swift\:.swift:\ :gtags_parser=Swift\:$ctagslib: pygments:\ :tc=pygments-parser: pygments-parser|Pygments plug-in parser:\ :langmap=Swift\:.swift:\ :gtags_parser=Swift\:$pygmentslib:\ :langmap=Common-Lisp\:.cl.lisp.el:\ :gtags_parser=Common-Lisp\:$pygmentslib:\ :langmap=Python\:.py.pyw.sc.tac.sage:\ :gtags_parser=Python\:$pygmentslib:\ :langmap=Ruby\:.rb.rbw.rake.gemspec.rbx.duby:\ :gtags_parser=Ruby\:$pygmentslib:\ :langmap=Objective-C++\:.mm.hh:\ :gtags_parser=Objective-C++\:$pygmentslib:\ :langmap=Objective-C\:.m.h:\ :gtags_parser=Objective-C\:$pygmentslib:\ :ctagscom=ctags:\ :pygmentslib=$libdir/gtags/pygments-parser.la:\ :tc=common: common:\ :skip=build/,HTML/,HTML.pub/,tags,TAGS,ID,y.tab.c,y.tab.h,gtags.files,cscope.files,cscope.out,cscope.po.out,cscope.in.out,SCCS/,RCS/,CVS/,CVSROOT/,{arch}/,autom4te.cache/,*.orig,*.rej,*.bak,*~,#*#,*.swp,*.tmp,*_flymake.*,*_flymake,*.o,*.a,*.so,*.lo,*.zip,*.gz,*.bz2,*.xz,*.lzh,*.Z,*.tgz,*.min.js,*min.css:
(use-package counsel-gtags :ensure t :commands counsel-gtags-mode :bind (:map counsel-gtags-mode-map ("M-." . counsel-gtags-dwim) ("M-," . counsel-gtags-go-backward)) :hook ((swift-mode . counsel-gtags-mode) (swift-mode . ggtags-mode))) ;; Needs .ctags and .globalrc in $HOME. (use-package ggtags :ensure t :commands ggtags-mode)
Helpful references
https://github.com/osdakira/dotfiles/blob/395640726d669674496a8035458840f0742e54a5/gtags.conf https://github.com/NicholasTD07/dotfiles/blob/e66eb05b408fbcb0d47994fc8a0a79bf438b9e03/.globalrc https://github.com/NicholasTD07/dotfiles/blob/master/.ctags https://github.com/sg2002/gtags.conf-tutorial/blob/master/gtags.conf https://aozsky.com/swift/swift_ide