How to generate tags for my haskell project?

时间:2018-03-25 18:44:06

标签: haskell tagging

I'm new to haskell, I have read almost all the documents about hasktags, fast-tags etc. None of them have the details about how I can generate tags using those tools?

I have installed both of them, but how can I first run and generate the tags file for my *.hs file? Can anyone please give me some details about what kind of command should I run, I have no idea what this means:

In order to generate tags for all Haskell files under current directory, issue fast-tags -o tags -R.

Where should I type this command? I tried fast-tags -o tags -R under my project directory, it didn't work, please help!

2 个答案:

答案 0 :(得分:3)

  1. Install hasktags. For example, cabal install hasktags (or use stack or your OS package manager).

  2. Make sure your shell's PATH includes the directory where the hasktags binary went. For cabal on *nix this is $HOME/.cabal/bin. For example, in the shell do export PATH=$HOME/.cabal/bin:$PATH. You should add a line like this into your $HOME/.profile.

  3. Change to your project directory.

  4. Invoke the hasktags binary with a call such as hasktags --ignore-close-implementation --ctags . Or just hasktags . depending on your needs.

EDIT: For example

% cabal unpack containers
Downloading containers-0.5.11.0...
Unpacking to containers-0.5.11.0/
% cd containers-0.5.11.0
containers-0.5.11.0% hasktags --ignore-close-implementation --ctags .
containers-0.5.11.0% ls TAGS
TAGS
% vim

Then in vi/vim/neovim type Map, move the cursor over the word and hit ctrl-]. It should open to the Internal.hs file line ~ 459.

I have an extra binding to open a new tab. In my init.vim (or your .vimrc) consider adding:

" Open tags in new tabs (via C-[)
nnoremap <silent><C-[> <C-w><C-]><C-w>T

答案 1 :(得分:2)

You can literally just go to your project directory and run:

hasktags .

(When I say "go" and "run", I imply an ordinary POSIX compatible shell.)

You will obtain a file called tags in that same directory.


In order to run hasktags, you should first install it, of course. To do that, you may say:

stack install hasktags

(I am assuming you have stack on your system already.)

— It should do the job. The executable hasktags will be placed at ~/.local/bin/hasktags, so you may want to add ~/.local/bin to your PATH, or just run ~/.local/bin/hasktags instead of hasktags every time.