From e5f9b8f56b6cad569e960a9d1a8653d80a75faea Mon Sep 17 00:00:00 2001 From: utubo Date: Wed, 4 Dec 2024 10:04:44 +0900 Subject: [PATCH] =?UTF-8?q?=E2=9C=A8feat:=20tabline=E3=81=A8bufline?= =?UTF-8?q?=E3=82=92=E7=A7=BB=E5=8B=95=E6=99=82=E3=81=A0=E3=81=91=E8=A1=A8?= =?UTF-8?q?=E7=A4=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .vim/autoload/vimrc/bufline.vim | 53 ++++---------------- .vim/autoload/vimrc/lazyload.vim | 40 ++++++++------- src/.vim/autoload/vimrc/bufline.src.vim | 62 ++---------------------- src/.vim/autoload/vimrc/lazyload.src.vim | 24 ++++++--- 4 files changed, 51 insertions(+), 128 deletions(-) diff --git a/.vim/autoload/vimrc/bufline.vim b/.vim/autoload/vimrc/bufline.vim index f84c0fe..ed7b2d1 100644 --- a/.vim/autoload/vimrc/bufline.vim +++ b/.vim/autoload/vimrc/bufline.vim @@ -1,11 +1,10 @@ vim9script g:buflist_term_sign = get(g:, 'buflist_term_sign', "\uf489") -var k = 0 +var k = '' var n = '' -var q = '' -var t = '' +var p = '' def A() -q = '' +n = '' var a = [] const b = execute('ls')->split("\n") const c = &columns / (!b ? 1 : len(b)) @@ -29,51 +28,17 @@ endif const h = $'{e}:{f}' const i = m[2][0] ==# '%' if i -n = a->join(' ') -q = (!n ? '' : ' ') .. h .. ' ' +k = a->join(' ') +n = (!k ? '' : ' ') .. h .. ' ' a = [] else add(a, h) endif endfor -t = a->join(' ') +p = a->join(' ') enddef -export def Popup() -if !n && !t -return -endif -var w = &columns -const o = getwininfo(win_getid(1))[0].textoff -w -= o -const s = q->substitute($'\%{w}v.*', '', '') -w -= strdisplaywidth(s) -var l = n->reverse()->substitute($'\%{w}v.*', '', '')->reverse() -if l !=# n -l = l->substitute('^.', '<', '') -endif -w -= strdisplaywidth(l) -var r = t->substitute($'\%{w}v.*', '', '') -if r !=# t -r = r->substitute('.$', '>', '') -endif -w -= strdisplaywidth(r) -const p = max([0, w]) -var a = popup_create($'{l}{s}{r}', { -line: 1, -col: 1, -fixed: true, -highlight: 'TabLine', -padding: [0, p, 0, o], -moved: 'any', -}) -if !!k -popup_close(k) -endif -k = a -enddef -export def Show() +export def MyBufline(): string A() -Popup() -enddef -export def Setup() +const o = getwininfo(win_getid(1))[0].textoff +return $'{repeat(' ', o)}{k}%#TabLineSel#{n}%#TabLine#{p}' enddef diff --git a/.vim/autoload/vimrc/lazyload.vim b/.vim/autoload/vimrc/lazyload.vim index a0210ec..2879bb3 100644 --- a/.vim/autoload/vimrc/lazyload.vim +++ b/.vim/autoload/vimrc/lazyload.vim @@ -182,7 +182,6 @@ au vimrc SafeState * ++once B() enddef au vimrc BufReadPost * C() C() -Each n,p nmap g{} (buf)n|nm (buf){} b{}call vimrc#bufline#Show()(buf) g:recentBufnr = 0 au vimrc BufLeave * g:recentBufnr = bufnr() nn gr $"\b{g:recentBufnr}\" @@ -251,14 +250,21 @@ echoh Normal echow expand('%:p:h') enddef nn