From 464532e0347758d2a498adee6433598ab74fcdc5 Mon Sep 17 00:00:00 2001 From: baabelfish Date: Thu, 11 Feb 2016 09:37:12 +0200 Subject: [PATCH] Fixes --- autoload/features/outline.vim | 37 +++++++++++++++++--------- autoload/unite/sources/outline/nim.vim | 14 ++++++++++ plugin/nim.vim | 1 + syntax/nimoutline.vim | 2 ++ 4 files changed, 42 insertions(+), 12 deletions(-) create mode 100644 autoload/unite/sources/outline/nim.vim diff --git a/autoload/features/outline.vim b/autoload/features/outline.vim index 8260323..c63b7b0 100644 --- a/autoload/features/outline.vim +++ b/autoload/features/outline.vim @@ -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 diff --git a/autoload/unite/sources/outline/nim.vim b/autoload/unite/sources/outline/nim.vim new file mode 100644 index 0000000..f1a978b --- /dev/null +++ b/autoload/unite/sources/outline/nim.vim @@ -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 diff --git a/plugin/nim.vim b/plugin/nim.vim index 3b2c51d..90bb42f 100644 --- a/plugin/nim.vim +++ b/plugin/nim.vim @@ -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 diff --git a/syntax/nimoutline.vim b/syntax/nimoutline.vim index a87e094..1d133be 100644 --- a/syntax/nimoutline.vim +++ b/syntax/nimoutline.vim @@ -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