[Haskell-cafe] Generating tagfiles for Vim

Nathan Merkley nathanmerkley at gmail.com
Mon Apr 1 15:56:20 UTC 2019


While there is probably a better way, my limited knowledge of vimscript had
me write this and it works well enough


function! UpdateHaskellTags()
    if filereadable("tags")
        execute "silent !grep -v '" . bufname("%") . "' ./tags > __newtags"
        execute "silent !rm tags"
        execute "silent !mv __newtags tags"
        execute "silent !fast-tags " . bufname("%")
    endif
endfunction

autocmd BufWritePost *.hs :call UpdateHaskellTags()
autocmd BufWritePost *.hsc :call UpdateHaskellTags()


This uses fast-tags to regenerate tags for the current file on every save,
but will only work if you are operating from the root of your project (or
wherever you keep your tags). I use ctrlp for navigation so that's never
been a problem for me

Nathan Merkley

On Mon, Apr 1, 2019 at 9:26 AM Vanessa McHale <vanessa.mchale at iohk.io>
wrote:

> Hi all,
>
> I had been using hasktags for tag generation previously, however, I
> recently discovered that using GHCi with
>
> cabal new-repl
> λ:> :ctags
>
> creates a tags file that actually works with preprocessors (e.g. c2hs or
> alex or happy).
>
> Is there any way to run this semi-automatically?
>
> echo ':ctags' | cabal new-repl
>
> seems to work in the shell, but I'd like a vim integration if possible
> (also, it's slow).
>
> Cheers,
> Vanessa McHale
>
>
> _______________________________________________
> Haskell-Cafe mailing list
> To (un)subscribe, modify options or view archives go to:
> http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe
> Only members subscribed via the mailman list are allowed to post.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.haskell.org/pipermail/haskell-cafe/attachments/20190401/8cd1b58e/attachment.html>


More information about the Haskell-Cafe mailing list