index all rss twitter github linkedin email

Álvaro Ramírez

04 June 2019 gnu global, ctags, and Emacs setup

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