Skip to content

Commit

Permalink
Unify FromJSON and FromRaw parser
Browse files Browse the repository at this point in the history
  • Loading branch information
liuchengxu committed Apr 24, 2019
1 parent 994bc3e commit 268a88d
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 37 deletions.
2 changes: 2 additions & 0 deletions autoload/vista/executive/ctags.vim
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ let s:ctags = get(g:, 'vista_ctags_executable', 'ctags')
let s:support_json_format =
\ len(filter(split(system(s:ctags.' --list-features'), '\n'), 'v:val =~# ''^json''')) > 0

let g:vista#executive#ctags#support_json_format = s:support_json_format

function! s:GetCustomCmd(ft) abort
if exists('g:vista_ctags_cmd') && has_key(g:vista_ctags_cmd, a:ft)
return g:vista_ctags_cmd[a:ft]
Expand Down
70 changes: 33 additions & 37 deletions autoload/vista/parser/ctags.vim
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,37 @@ function! s:Insert(container, kind, picked) abort
endif
endfunction

function! s:LoadData(container, line) abort
let line = a:line

let kind = line.kind

call s:Insert(t:vista.raw_by_kind, kind, line)

call add(t:vista.raw, line)

if has_key(line, 'scope')
call add(t:vista.with_scope, line)
else
call add(t:vista.without_scope, line)
endif

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

if index(t:vista.kinds, kind) == -1
call add(t:vista.kinds, kind)
endif

call s:Insert(a:container, kind, picked)
endfunction

" Parse the output from ctags linewise and feed them into the container
" The parsed result should be compatible with the LSP output.
"
Expand Down Expand Up @@ -84,18 +115,7 @@ function! vista#parser#ctags#FromExtendedRaw(line, container) abort

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)
call s:LoadData(a:container, line)

endfunction

Expand All @@ -106,32 +126,8 @@ function! vista#parser#ctags#FromJSON(line, container) abort

let line = json_decode(a:line)

call add(t:vista.raw, line)

let kind = line.kind

call s:Insert(t:vista.raw_by_kind, kind, line)

if has_key(line, 'scope')
call add(t:vista.with_scope, line)
else
call add(t:vista.without_scope, line)
endif

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

if index(t:vista.kinds, kind) == -1
call add(t:vista.kinds, kind)
endif
call s:LoadData(a:container, line)

call s:Insert(a:container, kind, picked)
endfunction

" ctags -R -x --_xformat='TAGNAME:%N ++++ KIND:%K ++++ LINE:%n ++++ INPUT-FILE:%F ++++ PATTERN:%P'"
Expand Down
2 changes: 2 additions & 0 deletions autoload/vista/renderer.vim
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,10 @@
let s:icons = {
\ 'func': "\uf794",
\ 'function': "\uf794",
\ 'functions': "\uf794",
\ 'var': "\uf71b",
\ 'variable': "\uf71b",
\ 'variables': "\uf71b",
\ 'const': "\uf8ff",
\ 'constant': "\uf8ff",
\ 'method': "\uf6a6",
Expand Down

0 comments on commit 268a88d

Please sign in to comment.