Skip to content

Instantly share code, notes, and snippets.

@jberryman
Created July 8, 2019 14:20
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jberryman/d8f0a3f5aefe8ae9da8830d0007eab0f to your computer and use it in GitHub Desktop.
Save jberryman/d8f0a3f5aefe8ae9da8830d0007eab0f to your computer and use it in GitHub Desktop.
Using hasktags with vim-gutentags for Haskell ctags
#!/bin/bash
set -euo pipefail
#
# A hack to get hasktags working with vim-gutentags
#
# In vimrc:
#
# let g:gutentags_project_info = []
# call add(g:gutentags_project_info, {'type': 'haskell', 'file': 'stack.yaml'})
# call add(g:gutentags_project_info, {'type': 'haskell', 'glob': '*.cabal'})
# let g:gutentags_ctags_executable_haskell = 'hasktags-gutentags-shim.sh'
#
append=0 # Ignored
while [[ "$#" -gt 0 ]]; do case $1 in
-f|--file) tagsfile="$2"; shift;;
--options=*) options="${1#*=}" ;; # Ignored; used for some reason to pass --recurse=true
-a|--append) append=1 ;;
*) path="$1" ;; # Assume last param
esac; shift; done
# This lets us ignore `--append`:
touch "$tagsfile"
# ASCII merge changed file tags with (possibly empty) existing tags:
hasktags -R -c --file - "$path" |\
LC_ALL=C sort -m "$tagsfile" - -o "$tagsfile"
@jberryman
Copy link
Author

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment