This commit is contained in:
baabelfish 2016-02-11 09:37:12 +02:00
commit 464532e034
4 changed files with 42 additions and 12 deletions

View file

@ -56,8 +56,12 @@ let s:group_aliases = {
\ 'skPackage': "Imports", \ 'skPackage': "Imports",
\ } \ }
function! s:CreateSymbolRow(symbol) function! s:CreateSymbolRow(symbol, active)
let result = " » " . a:symbol.name if g:nvim_nim_outline_track_symbol && a:active
let result = " «» " . a:symbol.name
else
let result = " » " . a:symbol.name
endif
if len(s:symbols[a:symbol.kind]) > 0 if len(s:symbols[a:symbol.kind]) > 0
let result .= " (" . s:symbols[a:symbol.kind] . ")" let result .= " (" . s:symbols[a:symbol.kind] . ")"
endif endif
@ -69,18 +73,16 @@ function! s:FindClosest()
return return
endif endif
echoerr join(sort(map(keys(s:buffermap), 'str2nr(v:val)'), "n"), ", ")
let bline = line(".") let bline = line(".")
let closest = 1 let closest = 1
for l in sort(map(keys(s:buffermap), 'str2nr(v:val)'), "n") for l in sort(map(keys(s:buffermap), 'str2nr(v:val)'), "n")
if l < bline if l < bline
let closest = l let closest = l
else else
break return closest
endif endif
endfor endfor
return 0
echom closest
endfunction endfunction
function! s:ConfigureOutlineBuffer() function! s:ConfigureOutlineBuffer()
@ -130,8 +132,11 @@ endfunction
function! s:RenderOutline() function! s:RenderOutline()
let wasFocused = s:IsFocused() let wasFocused = s:IsFocused()
let closest = 0
call s:FindClosest() if g:nvim_nim_outline_track_symbol
let closest = s:FindClosest()
endif
call s:Focus() call s:Focus()
if !s:IsFocused() if !s:IsFocused()
@ -155,8 +160,10 @@ function! s:RenderOutline()
for symbol in s:groups[groupname] for symbol in s:groups[groupname]
let s:goto_table[len(rlines) + 1] = [symbol.line, symbol.col] let s:goto_table[len(rlines) + 1] = [symbol.line, symbol.col]
let s:goto_table[symbol.line] = [len(rlines) + 1] if g:nvim_nim_outline_track_symbol
call add(rlines, s:CreateSymbolRow(symbol)) let s:buffermap[symbol.line] = len(rlines) + 1
endif
call add(rlines, s:CreateSymbolRow(symbol, closest == symbol.line))
endfor endfor
call add(rlines, "") call add(rlines, "")
endfor endfor
@ -170,9 +177,15 @@ function! s:RenderOutline()
exec ":" . len(rlines) exec ":" . len(rlines)
normal! dG normal! dG
call cursor(w0, 1) if !wasFocused && g:nvim_nim_outline_track_symbol && closest != 0
normal zt call cursor(s:buffermap[closest], 2)
call cursor(l, 2) normal zz
normal ^
else
call cursor(w0, 1)
normal zt
call cursor(l, 2)
endif
if !wasFocused if !wasFocused
wincmd p wincmd p

View file

@ -0,0 +1,14 @@
let s:Tree = unite#sources#outline#import('Tree')
let s:OutlineInfo = {
\ 'auto-update': 0}
function! unite#sources#outline#nim#outline_info()
return s:OutlineInfo
endfunction
function! s:OutlineInfo.extract_headings(context)
let root = s:Tree.new()
call s:Tree.append_child(root, {})
return root
endfunction

View file

@ -45,6 +45,7 @@ let g:nvim_nim_enable_async = 1
let g:nvim_nim_highlight_builtin = 1 let g:nvim_nim_highlight_builtin = 1
let g:nvim_nim_highlight_use_unite = 0 let g:nvim_nim_highlight_use_unite = 0
let g:nvim_nim_outline_track_symbol = 1
let g:nvim_nim_outline_buffer = 1 let g:nvim_nim_outline_buffer = 1
let g:nvim_nim_outline_buffer_width = 30 let g:nvim_nim_outline_buffer_width = 30

View file

@ -8,6 +8,7 @@ syntax keyword nimoGlobals Globals
syntax keyword nimoImports Imports syntax keyword nimoImports Imports
syntax match nimoSeparator "[»()<>\[\]]" syntax match nimoSeparator "[»()<>\[\]]"
syntax match nimoActive "«»\s.*$"
syntax match nimoDetail "(\(\w\+\))" syntax match nimoDetail "(\(\w\+\))"
hi link nimoConstants Constant hi link nimoConstants Constant
@ -24,6 +25,7 @@ hi link nimoProcs Function
hi link nimoTemplates Function hi link nimoTemplates Function
hi link nimoTypes Type hi link nimoTypes Type
hi link nimoSeparator Comment hi link nimoSeparator Comment
hi link nimoActive Typedef
hi link nimoTypes Type hi link nimoTypes Type
hi link nimoCallables Function hi link nimoCallables Function