Fixes
This commit is contained in:
parent
6b16dade7c
commit
464532e034
4 changed files with 42 additions and 12 deletions
|
|
@ -56,8 +56,12 @@ let s:group_aliases = {
|
|||
\ 'skPackage': "Imports",
|
||||
\ }
|
||||
|
||||
function! s:CreateSymbolRow(symbol)
|
||||
let result = " » " . a:symbol.name
|
||||
function! s:CreateSymbolRow(symbol, active)
|
||||
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
|
||||
let result .= " (" . s:symbols[a:symbol.kind] . ")"
|
||||
endif
|
||||
|
|
@ -69,18 +73,16 @@ function! s:FindClosest()
|
|||
return
|
||||
endif
|
||||
|
||||
echoerr join(sort(map(keys(s:buffermap), 'str2nr(v:val)'), "n"), ", ")
|
||||
let bline = line(".")
|
||||
let closest = 1
|
||||
for l in sort(map(keys(s:buffermap), 'str2nr(v:val)'), "n")
|
||||
if l < bline
|
||||
let closest = l
|
||||
else
|
||||
break
|
||||
return closest
|
||||
endif
|
||||
endfor
|
||||
|
||||
echom closest
|
||||
return 0
|
||||
endfunction
|
||||
|
||||
function! s:ConfigureOutlineBuffer()
|
||||
|
|
@ -130,8 +132,11 @@ endfunction
|
|||
|
||||
function! s:RenderOutline()
|
||||
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()
|
||||
if !s:IsFocused()
|
||||
|
|
@ -155,8 +160,10 @@ function! s:RenderOutline()
|
|||
|
||||
for symbol in s:groups[groupname]
|
||||
let s:goto_table[len(rlines) + 1] = [symbol.line, symbol.col]
|
||||
let s:goto_table[symbol.line] = [len(rlines) + 1]
|
||||
call add(rlines, s:CreateSymbolRow(symbol))
|
||||
if g:nvim_nim_outline_track_symbol
|
||||
let s:buffermap[symbol.line] = len(rlines) + 1
|
||||
endif
|
||||
call add(rlines, s:CreateSymbolRow(symbol, closest == symbol.line))
|
||||
endfor
|
||||
call add(rlines, "")
|
||||
endfor
|
||||
|
|
@ -170,9 +177,15 @@ function! s:RenderOutline()
|
|||
exec ":" . len(rlines)
|
||||
normal! dG
|
||||
|
||||
call cursor(w0, 1)
|
||||
normal zt
|
||||
call cursor(l, 2)
|
||||
if !wasFocused && g:nvim_nim_outline_track_symbol && closest != 0
|
||||
call cursor(s:buffermap[closest], 2)
|
||||
normal zz
|
||||
normal ^
|
||||
else
|
||||
call cursor(w0, 1)
|
||||
normal zt
|
||||
call cursor(l, 2)
|
||||
endif
|
||||
|
||||
if !wasFocused
|
||||
wincmd p
|
||||
|
|
|
|||
14
autoload/unite/sources/outline/nim.vim
Normal file
14
autoload/unite/sources/outline/nim.vim
Normal 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
|
||||
|
|
@ -45,6 +45,7 @@ let g:nvim_nim_enable_async = 1
|
|||
let g:nvim_nim_highlight_builtin = 1
|
||||
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_width = 30
|
||||
|
||||
|
|
|
|||
|
|
@ -8,6 +8,7 @@ syntax keyword nimoGlobals Globals
|
|||
syntax keyword nimoImports Imports
|
||||
|
||||
syntax match nimoSeparator "[»()<>\[\]]"
|
||||
syntax match nimoActive "«»\s.*$"
|
||||
syntax match nimoDetail "(\(\w\+\))"
|
||||
|
||||
hi link nimoConstants Constant
|
||||
|
|
@ -24,6 +25,7 @@ hi link nimoProcs Function
|
|||
hi link nimoTemplates Function
|
||||
hi link nimoTypes Type
|
||||
hi link nimoSeparator Comment
|
||||
hi link nimoActive Typedef
|
||||
|
||||
hi link nimoTypes Type
|
||||
hi link nimoCallables Function
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue