Ghc Tags Plugin published on hackage
Getting vim tags from Haskell's parsed tree
Working on a large code base, which many type level features could be
easier with a proper editor support. Finding associated type class
instances or open type families isn't easy at the moment. Existing
solutions like hasktags do not
cover all the new language features, so at times one is left
is searching the tree by hand. Haskell IDE engine, will deliver a very
good solution, but at this time it is still quite hard to find a good
language client for vim
which works out of the box.
Ghc plugin is a good fit for solving this problem, and here are the reasons why:
CPP
pragmas are resolved;- it doesn't matter whether you write literate haskell, regular
haskell or you are using
hsc2hs
or some other preprocessor; - contains accurate source information;
- one can derive additional information: tag kinds, whether its static or not (i.e. exported or not) - vim decides how to order tags depending on this information;
- regularly updated, as you build your project; possibly it could be
integrated with
ghcid
(I haven't tried yet).
Over last two weeks I worked out a quite nice solution ghc-tags-plugin using ghc plugin system: at the moment only the part which has access to parsed tree. This allows to output tags for:
- top level terms
- data types
- record fields
- type synonyms
- type classes
- type class members
- type class instances
- type families standalone and associated
- type family instances standalone and associated
- data type families standalone and associated
- data type families instances standalone and associated
- data type family instances constructors standalone and associated
- tag kinds (as given above)
- whether terms, type constructor, class method, etc. are exported or not
- its tags file parser is compatible with output of
ctags
, so if you want you could append tags generated byctags
(i.e. forC
in your project).
Configuration is simple (and possibly can be still improved). For
cabal
you don't need to modify checked files (only
cabal.project.local
). Check out the readme
file for instructions.
If you encounter problems with installation, the
github repo contains
a Makefile
to remove the plugin from the cabal store,
install it, list installed versions. This turned out to be quite useful
during development (co-existence of the same version of the plugin which
depends on an internal library may cause problems).
I have been using this plugin on a daily basis while working on
IOHK
code base which contains
haskell: 214521 (96.22%) ansic: 5285 (2.37%) sh: 1868 (0.84%) javascript: 1019 (0.46%) cpp: 197 (0.09%) perl: 63 (0.03%) lisp: 7 (0.00%)Navigating the codebase, re-discovering where things were moved after a refactoring, discovering code in far away from my area of expertise became much easier.
It has been tested on Windows
and Linux
. The
only requirement is: GHC
version 8.6.5
or later.
Happy Haskelling!