<div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div>Here is a very useful bash script to have lying around:<br><div style="margin-left:40px"><span style="font-family:monospace,monospace">#!/usr/bin/env bash<br></span></div><div style="margin-left:40px"><span style="font-family:monospace,monospace">shopt -s nullglob<br>while true; do<br>  if [[  "$PWD" == "$HOME" <br>      || "$PWD" == / <br>      || -f "$PWD/package.yaml" <br>      || -f "$PWD/stack.yaml" <br>      || -n "$(echo -n ./*.cabal)" ]]; then<br>    exec "$@"<br>  else<br>    cd ..<br>  fi<br>done</span><br></div></div><div><br></div><div>Name this something like "run-in-project-root", and then you can prefix any command you run with "run-in-project-root" in order for it to run in the project's root, as defined by the existence of a package.yaml or stack.yaml or *.cabal file. (Of course you can customize the exact condition to your tastes.) So running "run-in-project-root fast-tags filename" is exactly like running "fast-tags filename" except that fast-tags will execute in the project root. (And the same for all the other shell commands that you run.)<br></div><div><br></div><div>Of course, this works both when running fast-tags (or any other command) directly in the shell, and when running a bash snippet in vim with :!, so long as the "run-in-project-root" script is in a directory that's in your $PATH.<br></div><br></div></div></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Mon, Apr 1, 2019 at 5:56 PM Nathan Merkley <<a href="mailto:nathanmerkley@gmail.com">nathanmerkley@gmail.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div dir="ltr">While there is probably a better way, my limited knowledge of vimscript had me write this and it works well enough<div><br></div><div><br></div><div><div>function! UpdateHaskellTags()</div><div>    if filereadable("tags")</div><div>        execute "silent !grep -v '" . bufname("%") . "' ./tags > __newtags"</div><div>        execute "silent !rm tags"</div><div>        execute "silent !mv __newtags tags"</div><div>        execute "silent !fast-tags " . bufname("%")</div><div>    endif</div><div>endfunction</div><div><br></div><div>autocmd BufWritePost *.hs :call UpdateHaskellTags()</div><div>autocmd BufWritePost *.hsc :call UpdateHaskellTags()</div></div><div><br></div><div><br></div></div><div>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</div><div><br></div><div>Nathan Merkley</div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Mon, Apr 1, 2019 at 9:26 AM Vanessa McHale <<a href="mailto:vanessa.mchale@iohk.io" target="_blank">vanessa.mchale@iohk.io</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">Hi all,<br>
<br>
I had been using hasktags for tag generation previously, however, I<br>
recently discovered that using GHCi with<br>
<br>
cabal new-repl<br>
λ:> :ctags<br>
<br>
creates a tags file that actually works with preprocessors (e.g. c2hs or<br>
alex or happy).<br>
<br>
Is there any way to run this semi-automatically?<br>
<br>
echo ':ctags' | cabal new-repl<br>
<br>
seems to work in the shell, but I'd like a vim integration if possible<br>
(also, it's slow).<br>
<br>
Cheers,<br>
Vanessa McHale<br>
<br>
<br>
_______________________________________________<br>
Haskell-Cafe mailing list<br>
To (un)subscribe, modify options or view archives go to:<br>
<a href="http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe" rel="noreferrer" target="_blank">http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe</a><br>
Only members subscribed via the mailman list are allowed to post.</blockquote></div>
_______________________________________________<br>
Haskell-Cafe mailing list<br>
To (un)subscribe, modify options or view archives go to:<br>
<a href="http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe" rel="noreferrer" target="_blank">http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe</a><br>
Only members subscribed via the mailman list are allowed to post.</blockquote></div>