-
-
Notifications
You must be signed in to change notification settings - Fork 87
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Refine ctags with language specific kinds #35
Conversation
@liuchengxu let g:vista_ctags_cmd = {
\ 'haskell': 'hasktags -o - -c',
\ } Extended ctags with
Extended also produces
|
First of all, I recommend you compile the ctags with |
I have pushed some commits to fix your issue. You should use let g:vista_ctags_cmd = {
\ 'haskell': 'hasktags -o - -x',
\ } Do you know how to distinguish the extended and non-extended options rationally? |
hasktags does not have a json option. To determine format look at: It works with extended now, but not normal ctags. Thanks |
Seems to work ok, although I need to pass specific ctags options taken from the code:
|
I think |
The ctag/extended format is pretty well defined why use json output? |
You need to extract the key/value on your own if using the ctag/extended format. function! s:ParseTagfield(tagfields) abort
let fields = {}
if stridx(a:tagfields[0], ':') > -1
let colon = stridx(a:tagfields[0], ':')
let value = tagfield[colon+1:]
let fields.kind = value
else
let fields.kind = s:ShortToLong(a:tagfields[0])
endif
if len(a:tagfields) > 1
for tagfield in a:tagfields[1:]
let colon = stridx(tagfield, ':')
let name = tagfield[0:colon-1]
let value = tagfield[colon+1:]
let fields[name] = value
endfor
endif
return fields
endfunction
function! vista#parser#ctags#FromRaw(line, container) abort
if a:line =~ '^!_TAG'
return
endif
let items = split(a:line, '\t')
let line = {}
let line.name = items[0]
let line.tagfile = items[1]
let line.tagaddress = items[2]
let tagfields = s:ParseTagfield(items[3:])
call extend(line, tagfields)
let kind = line.kind
let picked = {'lnum': line.line, 'text': line.name}
if kind =~# '^f' || kind =~# '^m'
if has_key(line, 'signature')
let picked.signature = line.signature
endif
call add(t:vista.functions, picked)
endif
call s:Insert(a:container, kind, picked)
endfunction With json ouptut, function! vista#parser#ctags#FromJSON(line, container) abort
let line = json_decode(a:line)
let kind = line.kind
let picked = {'lnum': line.line, 'text': line.name }
if kind =~# '^f' || kind =~# '^m'
if has_key(line, 'signature')
let picked.signature = line.signature
endif
call add(t:vista.functions, picked)
endif
call s:Insert(a:container, kind, picked)
endfunction The json output is definitely more reliable IMO. |
My 2c. I think JSON format support is still fairly uncommon. I don't have the libjansson library available for my platform without going out of my way. I have no doubt JSON is easier to code for, but if you choose to support non-json then the non-json parser would still need to be written anyway. You may as well only write one parser rather than two. Maintenance-wise it is much better to just have the one. As far as modernisation/reliability is concerned, LSP should be the next step forward for people with those concerns. |
@liuchengxu I can see how json is simpler, just as long as ctag format is also supported. I think the default for custom commands should remain non json, so that the parser can rely on the header to determine format. The following should be detected as original ctags by the parser. let g:vista_ctags_cmd = {
\ 'haskell': 'hasktags -o - -c',
\ } |
I'm actually not against supporting the both since they have been done mostly already, just need to coordinate them right. I think there is no need to check whether the output is extended for json format. Currently I just check if the |
924e701
to
1bd2b5d
Compare
@Avi-D-coder Does |
@liuchengxu It appears not. Tagbar is integrated with lushtags so I never used hasktags with it. |
So, in this PR, we add the support of parsing extended ctags, which fixes #4. Although there still some remaining problems:
These problems will be resolved later, I think this PR is good to merge if the extended ctags parser works well. @Avi-D-coder @smhc What do you think? |
@liuchengxu Thanks for all your work |
this should be in another PR.
…sta.vim into refine-ctags-kinds
Fixes #4
This PR introduces more detailed kinds for various language(thanks to tagbar) and refactor the ctags parser to work with new options. However, these extra information has not been utilized nicely, which will be improved later.