Set up tags with Vim

From Lift

Jump to: navigation, search

This is how I set up /Lift/, ctags, and vim (on OS X and Ubuntu):

Contents

Add some scala definition to ctags:

ty@Astra:~$ cat /home/ty/.ctags
--langdef=scala
--langmap=scala:.scala
--regex-scala=/^[ \t]*class[ \t]+([a-zA-Z0-9_]+)/\1/c,classes/
--regex-scala=/^[ \t]*trait[ \t]+([a-zA-Z0-9_]+)/\1/t,traits/
--regex-scala=/^[ \t]*type[ \t]+([a-zA-Z0-9_]+)/\1/T,types/
--regex-scala=/^[ \t]*def[ \t]+([a-zA-Z0-9_]+)/\1/m,methods/
--regex-scala=/^[ \t]*val[ \t]+([a-zA-Z0-9_]+)/\1/C,constants/
--regex-scala=/^[ \t]*var[ \t]+([a-zA-Z0-9_]+)/\1/l,local variables/
--regex-scala=/^[ \t]*package[ \t]+([a-zA-Z0-9_.]+)/\1/p,packages/
--regex-scala=/^[ \t]*case class[ \t]+([a-zA-Z0-9_]+)/\1/c,case classes/
--regex-scala=/^[ \t]*object[ \t]+([a-zA-Z0-9_]+)/\1/o,objects/

Build the tags file:

ty@Astra:~$ ctags -h [".scala"] -R -f liftags /home/ty/liftweb-read-only/liftweb/

I prefer to keep the tags file, in this case liftags, in the root of home. Put it where you want.

Add the tags location to ~/.vimrc

set tags=/home/ty/liftags

Now you can open a file and execute

:tag LiftSession

and you'll jump to the file.

Using taglist

If you use taglist, just add this to make it work:

 462 " scala language
 463 let s:tlist_def_scala_settings = 'scala;p:package;c:class;t:trait;' .
 464                                \ 'T:type;m:method;' .
 465                                \ 'c:case class;o:object;' .
 466                                \ 'C:constant;l:local variable'
Personal tools