diff --git a/autoload/vim2hs/haskell/tags.vim b/autoload/vim2hs/haskell/tags.vim new file mode 100644 index 0000000..04f1bbe --- /dev/null +++ b/autoload/vim2hs/haskell/tags.vim @@ -0,0 +1,8 @@ +function! vim2hs#haskell#tags#fasttags() " {{{ + silent !find -iname '*.hs' | xargs fast-tags +endfunction " }}} + + +function! vim2hs#haskell#tags#hasktags() " {{{ + silent !hasktags -c --ignore-close-implementation . +endfunction " }}} diff --git a/doc/vim2hs.txt b/doc/vim2hs.txt index e69aa7e..b148ef9 100644 --- a/doc/vim2hs.txt +++ b/doc/vim2hs.txt @@ -116,5 +116,19 @@ Whether to add named patterns to Tabular useful for Haskell development. This is enabled by default if Tabular is installed: > let g:haskell_tabular = 1 < + *g:haskell_autotags* +Generate a tags file when Vim is started in a directory containing a "*.cabal" +file, and update it when saving "*.hs" files. + +See also |g:haskell_tags_generator|. + +Disabled by default: > + let g:haskell_autotags = 0 +< + *g:haskell_tags_generator* +The program to use for |g:haskell_autotags|. Valid values are "fast-tags" and +"hasktags" and requires the respective packages from Hackage. Default: > + let g:haskell_tags_generator = 'fast-tags' +< vim:tw=78:et:ft=help:norl: diff --git a/plugin/haskell_tags.vim b/plugin/haskell_tags.vim new file mode 100644 index 0000000..64d7e3e --- /dev/null +++ b/plugin/haskell_tags.vim @@ -0,0 +1,20 @@ +if glob('*.cabal') ==# '' + finish +endif + +call vim2hs#letdefault('g:haskell_autotags' , 0) +call vim2hs#letdefault('g:haskell_tags_generator' , 'fast-tags') + +if !g:haskell_autotags + finish +endif + +if g:haskell_tags_generator ==# 'fast-tags' + if !executable('fast-tags') | finish | endif + autocmd BufWritePost *.hs call vim2hs#haskell#tags#fasttags() + call vim2hs#haskell#tags#fasttags() +elseif g:haskell_tags_generator == 'hasktags' + if !executable('hasktags') | finish | endif + autocmd BufWritePost *.hs call vim2hs#haskell#tags#hasktags() + call vim2hs#haskell#tags#hasktags() +endif