mirror of
https://github.com/SpaceVim/SpaceVim.git
synced 2025-01-24 05:20:04 +08:00
Show buffer name when there are dup buf
This commit is contained in:
parent
c83c74830c
commit
d617c2338b
@ -1,7 +1,7 @@
|
||||
let s:self = {}
|
||||
|
||||
|
||||
function! s:self.build(left_sections, right_sections, lsep, rsep, hi_a, hi_b, hi_c, hi_z) abort
|
||||
function! s:self.build(left_sections, right_sections, lsep, rsep, fname, hi_a, hi_b, hi_c, hi_z) abort
|
||||
let l = '%#' . a:hi_a . '#' . a:left_sections[0]
|
||||
let l .= '%#' . a:hi_a . '_' . a:hi_b . '#' . a:lsep
|
||||
let flag = 1
|
||||
@ -24,9 +24,9 @@ function! s:self.build(left_sections, right_sections, lsep, rsep, hi_a, hi_b, hi
|
||||
endif
|
||||
endif
|
||||
if flag == 1
|
||||
let l .= '%#' . a:hi_c . '_' . a:hi_z . '#' . a:lsep . '%='
|
||||
let l .= '%#' . a:hi_c . '_' . a:hi_z . '#' . a:lsep . a:fname . '%='
|
||||
else
|
||||
let l .= '%#' . a:hi_b . '_' . a:hi_z . '#' . a:lsep . '%='
|
||||
let l .= '%#' . a:hi_b . '_' . a:hi_z . '#' . a:lsep . a:fname . '%='
|
||||
endif
|
||||
let l .= '%#' . a:hi_b . '_' . a:hi_z . '#' . a:rsep
|
||||
let flag = 1
|
||||
|
@ -86,6 +86,15 @@ function! s:check_mode() abort
|
||||
endif
|
||||
endfunction
|
||||
|
||||
" only when there are more than two buffers have same name.
|
||||
function! s:buffer_name() abort
|
||||
if get(b:, '_spacevim_statusline_showbfname', 0) == 1
|
||||
return ' ' . bufname('%')
|
||||
else
|
||||
return ''
|
||||
endif
|
||||
endfunction
|
||||
|
||||
function! s:search_status() abort
|
||||
let ct = 0
|
||||
let tt = 0
|
||||
@ -285,7 +294,8 @@ function! s:active() abort
|
||||
if index(s:loaded_sections, 'whitespace') != -1
|
||||
call add(rsec, s:whitespace())
|
||||
endif
|
||||
return s:STATUSLINE.build(lsec, rsec, s:lsep, s:rsep,
|
||||
let fname = s:buffer_name()
|
||||
return s:STATUSLINE.build(lsec, rsec, s:lsep, s:rsep, fname,
|
||||
\ 'SpaceVim_statusline_a', 'SpaceVim_statusline_b', 'SpaceVim_statusline_c', 'SpaceVim_statusline_z')
|
||||
endfunction
|
||||
|
||||
@ -386,7 +396,7 @@ function! SpaceVim#layers#core#statusline#config() abort
|
||||
\ 'toggle the statuline itself', 1)
|
||||
function! TagbarStatusline(...) abort
|
||||
let name = (strwidth(a:3) > (g:spacevim_sidebar_width - 15)) ? a:3[:g:spacevim_sidebar_width - 20] . '..' : a:3
|
||||
return s:STATUSLINE.build([s:winnr(),' Tagbar ', ' ' . name . ' '], [], s:lsep, s:rsep,
|
||||
return s:STATUSLINE.build([s:winnr(),' Tagbar ', ' ' . name . ' '], [], s:lsep, s:rsep, '',
|
||||
\ 'SpaceVim_statusline_ia', 'SpaceVim_statusline_b', 'SpaceVim_statusline_c', 'SpaceVim_statusline_z')
|
||||
endfunction
|
||||
let g:tagbar_status_func = 'TagbarStatusline'
|
||||
@ -415,7 +425,7 @@ endfunction
|
||||
" the marked filenames.
|
||||
function! SpaceVim#layers#core#statusline#ctrlp(focus, byfname, regex, prev, item, next, marked) abort
|
||||
return s:STATUSLINE.build([' Ctrlp ', ' ' . a:prev . ' ', ' ' . a:item . ' ', ' ' . a:next . ' '],
|
||||
\ [' ' . a:focus . ' ', ' ' . a:byfname . ' ', ' ' . getcwd() . ' '], s:lsep, s:rsep,
|
||||
\ [' ' . a:focus . ' ', ' ' . a:byfname . ' ', ' ' . getcwd() . ' '], s:lsep, s:rsep, '',
|
||||
\ 'SpaceVim_statusline_a_bold', 'SpaceVim_statusline_b', 'SpaceVim_statusline_c', 'SpaceVim_statusline_z')
|
||||
endfunction
|
||||
|
||||
@ -423,7 +433,7 @@ endfunction
|
||||
" the current directory is being scanned with a user_command.
|
||||
function! SpaceVim#layers#core#statusline#ctrlp_status(str) abort
|
||||
return s:STATUSLINE.build([' Ctrlp ', ' ' . a:str . ' '],
|
||||
\ [' ' . getcwd() . ' '], s:lsep, s:rsep,
|
||||
\ [' ' . getcwd() . ' '], s:lsep, s:rsep, '',
|
||||
\ 'SpaceVim_statusline_a', 'SpaceVim_statusline_b', 'SpaceVim_statusline_c', 'SpaceVim_statusline_z')
|
||||
endfunction
|
||||
|
||||
|
@ -58,9 +58,20 @@ function! s:tabname(id) abort
|
||||
endif
|
||||
endfunction
|
||||
|
||||
function! s:need_show_bfname(stack, nr) abort
|
||||
let dupbufs = filter(a:stack, "fnamemodify(bufname(v:val), ':t') ==# fnamemodify(bufname(a:nr), ':t')")
|
||||
if len(dupbufs) >= 2
|
||||
for i in dupbufs
|
||||
call setbufvar(i, '_spacevim_statusline_showbfname', 1)
|
||||
endfor
|
||||
endif
|
||||
endfunction
|
||||
|
||||
function! SpaceVim#layers#core#tabline#get() abort
|
||||
let nr = tabpagenr('$')
|
||||
let t = ''
|
||||
" the stack should be the bufnr stack of tabline
|
||||
let stack = []
|
||||
if nr > 1
|
||||
let ct = tabpagenr()
|
||||
if ct == 1
|
||||
@ -78,6 +89,8 @@ function! SpaceVim#layers#core#tabline#get() abort
|
||||
if empty(name)
|
||||
let name = 'No Name'
|
||||
endif
|
||||
call add(stack, buflist[winnr - 1])
|
||||
call s:need_show_bfname(stack, buflist[winnr - 1])
|
||||
if g:spacevim_buffer_index_type == 3
|
||||
let id = s:messletters.index_num(i)
|
||||
elseif g:spacevim_buffer_index_type == 4
|
||||
@ -123,6 +136,8 @@ function! SpaceVim#layers#core#tabline#get() abort
|
||||
if empty(name)
|
||||
let name = 'No Name'
|
||||
endif
|
||||
call add(stack, i)
|
||||
call s:need_show_bfname(stack, i)
|
||||
if g:spacevim_buffer_index_type == 3
|
||||
let id = s:messletters.index_num(index(s:buffers, i) + 1)
|
||||
elseif g:spacevim_buffer_index_type == 4
|
||||
|
Loading…
Reference in New Issue
Block a user