From 711707ebae1dfc7736ac3a42cd1c825d7db79ea9 Mon Sep 17 00:00:00 2001 From: Nachuan Tang Date: Sat, 11 Mar 2023 12:41:55 -0500 Subject: [PATCH 1/4] enter vista buffer will now jump to highlight --- .vimrc.bundles | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/.vimrc.bundles b/.vimrc.bundles index dfd347e..94538c7 100644 --- a/.vimrc.bundles +++ b/.vimrc.bundles @@ -176,6 +176,30 @@ endfunction let g:vista#renderer#enable_kind = 1 let g:vista#renderer#enable_icon = 1 + let g:vista_last_raw = v:null + function VistaCursorJump() + " let found = vista#util#BinarySearch(g:vista.raw, line('.'), 'line', '') + let found = g:vista_last_raw + if empty(found) + return + endif + let vlnum = get(found, 'vlnum', v:null) + call cursor(vlnum, 3) + endfunction + + function VistaH2() + if exists('*vista#util#BinarySearch') + let found = vista#util#BinarySearch(g:vista.raw, line('.'), 'line', '') + if empty(found) + return + endif + let g:vista_last_raw = found + endif + endfunction + + autocmd BufLeave * call VistaH2() + autocmd FileType vista call VistaCursorJump() + function VistaHelper() if winnr('$') == 1 && bufname() == "__vista__" let bufs = map(filter(copy(getbufinfo()), 'v:val.listed'), 'v:val.bufnr') @@ -186,6 +210,7 @@ endfunction endif endif endfunction + " close vista when it is the last window " autocmd BufEnter * if winnr('$') == 1 && bufname() == "__vista__" | execute "normal! :q!\" | endif " autocmd BufEnter * call VistaHelper() From 8009a07c036948d902b224d2547b8b0c1132eb73 Mon Sep 17 00:00:00 2001 From: Nachuan Tang Date: Sat, 11 Mar 2023 12:52:25 -0500 Subject: [PATCH 2/4] fix previous commit's buf --- .vimrc.bundles | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.vimrc.bundles b/.vimrc.bundles index 94538c7..367ee9d 100644 --- a/.vimrc.bundles +++ b/.vimrc.bundles @@ -189,6 +189,10 @@ endfunction function VistaH2() if exists('*vista#util#BinarySearch') + let bufs = map(filter(copy(getbufinfo()), 'v:val.listed'), 'v:val.bufnr') + if index(bufs, bufnr('%')) > 0 + return + endif let found = vista#util#BinarySearch(g:vista.raw, line('.'), 'line', '') if empty(found) return From f64b2256f102964f4662b00750c4a2105606f2cc Mon Sep 17 00:00:00 2001 From: Nachuan Tang Date: Sat, 11 Mar 2023 13:11:12 -0500 Subject: [PATCH 3/4] fix buf --- .vimrc.bundles | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/.vimrc.bundles b/.vimrc.bundles index 367ee9d..b0daba9 100644 --- a/.vimrc.bundles +++ b/.vimrc.bundles @@ -176,10 +176,10 @@ endfunction let g:vista#renderer#enable_kind = 1 let g:vista#renderer#enable_icon = 1 - let g:vista_last_raw = v:null + let g:vista_last_row = v:null function VistaCursorJump() " let found = vista#util#BinarySearch(g:vista.raw, line('.'), 'line', '') - let found = g:vista_last_raw + let found = g:vista_last_row if empty(found) return endif @@ -190,18 +190,20 @@ endfunction function VistaH2() if exists('*vista#util#BinarySearch') let bufs = map(filter(copy(getbufinfo()), 'v:val.listed'), 'v:val.bufnr') - if index(bufs, bufnr('%')) > 0 + if index(bufs, bufnr('%')) < 0 return endif let found = vista#util#BinarySearch(g:vista.raw, line('.'), 'line', '') if empty(found) return endif - let g:vista_last_raw = found + let g:vista_last_row = found endif endfunction + let count = 0 autocmd BufLeave * call VistaH2() + " autocmd WinLeave call VistaH2() autocmd FileType vista call VistaCursorJump() function VistaHelper() From 24589964e2ae5f6756a63661c67ec03f7cf11810 Mon Sep 17 00:00:00 2001 From: Nachuan Tang Date: Mon, 13 Mar 2023 03:14:49 -0400 Subject: [PATCH 4/4] . --- .vimrc.bundles | 1 - 1 file changed, 1 deletion(-) diff --git a/.vimrc.bundles b/.vimrc.bundles index b0daba9..d818a9e 100644 --- a/.vimrc.bundles +++ b/.vimrc.bundles @@ -201,7 +201,6 @@ endfunction endif endfunction - let count = 0 autocmd BufLeave * call VistaH2() " autocmd WinLeave call VistaH2() autocmd FileType vista call VistaCursorJump()