elaforge / fast-tags

Incremental vi and emacs tags for haskell.
http://hackage.haskell.org/package/fast-tags
BSD 3-Clause "New" or "Revised" License
76 stars 18 forks source link

tagbar doesn't recognize fast-tags output #39

Open osa1 opened 6 years ago

osa1 commented 6 years ago

I'm trying to add tagbar support for fast-tags. So far what I got is:

let g:tagbar_type_haskell = {
    \ 'ctagsbin'  : 'fast-tags',
    \ 'ctagsargs' : '-o-',
    \ 'kinds'     : [
        \  'm:modules:0:0',
        \  'c:classes:0:1',
        \  't:types:0:1',
        \  'C:constructors:0:1',
        \  'p:patterns:0:1',
        \  'o:operators:0:1',
        \  'f:functions:0:1'
    \ ],
    \ 'sro'        : '.',
    \ 'kind2scope' : {
        \ 'm' : 'module',
        \ 'c' : 'class',
        \ 'd' : 'data',
        \ 't' : 'type'
    \ },
    \ 'scope2kind' : {
        \ 'module' : 'm',
        \ 'class'  : 'c',
        \ 'data'   : 'd',
        \ 'type'   : 't'
    \ }
\ }

With this I can get a list of tags in a Haskell file. However, it seems like tagbar can't parse location information from the fast-tags output so I can't jump to a tag's location from the tag bar or can't show current tag in the status line.

It works with hasktags so I compared outputs. for the same tag this is what fast-tags generates:

writeetagsfile  src/Tags.hs 175;"   f

This is what hasktags generates

writeetagsfile  src/Tags.hs /^writeetagsfile :: Handle -> [FileData] -> IO ()$/;"   ft  signature:(Handle -> [FileData] -> IO ())   line:175    language:Haskell

It seems to me that we need to add the line number after f, like

writeetagsfile  src/Tags.hs 175;" line:175 language:Haskell

but I'm not sure as this stuff is not documented anywhere.

Any ideas? Possibly related: #19.

elaforge commented 6 years ago

It looks like just the f is an older syntax for kind:f. Probably vim makes x:y stuff available to plugins. This should be easy to add, but to avoid trial and error, can you test that tagbar like a line like the below:

writeetagsfile  src/Tags.hs 175;" kind:f line:175 language:Haskell
elaforge commented 6 years ago

BTW, fast-tags suppresses adjacent tags with the same name, so e.g. data T = T emits just one tag, not two. But that may not be appropriate for a type-oriented browsing thing, which tagbar looks like. If you get tagbar working and the suppression is getting in the way I can add a flag to turn that off.