sbt-ctags allows you to easily manage Exuberant ctags for your project dependencies.
For use with vim, Emacs, Sublime Text 2 and others.
First update your dependencies:
> ctagsDownload
Then select the dependency you wish to import for example scala-library
:
> ctagsAdd <tab>...
> ctagsAdd org.scala-lang:scala-library...
... or ...
> ctagsAdd org.scala-lang*
... or ...
> ctagsAdd *
This will extract the scala-library
source into .lib-src/org.scala-lang.scala-library/
and run ctags over the whole project including the imported sources. Both Java and Scala libs can be added.
Now you can use ctags to navigate the scala-library
source.
Make sure to add the following to your .gitignore
.lib-src
tags
ctags
You can remove a library for your tags file with:
> ctagsRemove <tab>...
> ctagsRemove org.scala-lang...
... or ...
> ctagsRemoveAll
... or ...
> ctagsRemove *
In one of these locations:
~/.sbt/plugins/plugin.sbt # for sbt 0.12
~/.sbt/0.13/plugins/plugins.sbt # for sbt 0.13
project/plugins.sbt # only for your project
Add:
addSbtPlugin("com.kalmanb.sbt" % "sbt-ctags" % "0.3.0")
Install exuberant-ctags / ctags as per your OS.
Then you'll need to have ctags configured with scala definitions. An example is in conf/ctags.example copy/append it to ~/.ctags
If you run the following you should get a tags
file created.
> cd <project>
> ctags
Add the following to you ~/.vimrc
set tags=./tags,tags,../tags
Please contribute
See (https://github.com/SublimeText/CTags)
> help ctagsDownload
> help ctagsAdd
> help ctagsShowCurrent
> help ctagsRemove
> help ctagsRemoveAll
The following can be customised as needed:
- The directory where sources are unzipped
- The command that gets called after ctagsAdd and ctagRemove. This allows you to call other external tools such as gtags etc.
For details on how to customise see: https://github.com/kalmanb/sbt-ctags/blob/master/conf/CustomCtagsPlugin.scala
Go for it!
> git clone https://github.com/kalmanb/sbt-ctags
> cd sbt-ctags
> sbt
> ^^0.12 # Change sbt version
> compile
> ^ clean # run command 'clean' for sbt versions
Testing, use the playground
> cd sbt-ctags
> sbt
> ^^0.13
> publish-local
> exit
> cd playground
> sbt
> ctagsDownload
Tip: you can run ~/publish-local
in the main dir and reload
in the playground to update and test
Features:
- Add ctagsRemoveAll
- Add ctagsShowCurrent
- Add version numbers to source directories
- Support wildcards in ctagsAdd and ctagsRemove
- Prepend [*NA] for modules without sources
Bugfixes:
- File not found exception when source not available
Features:
- Allow customisation of destination directory to store sources
- Allow customisation of command executed when new sources are added and removed
Initial version:
- Add ctagsDownload
- Add ctagsAdd
- Add ctagsRemove
See (https://github.com/kalmanb/sbt-ctags/issues)
Copyright (c) 2013 Kalman Bekesi
Published under the Apache License 2.0.