mirror of
https://github.com/SpaceVim/SpaceVim.git
synced 2025-01-24 02:10:05 +08:00
Improve tabline and statusline (#4169)
This commit is contained in:
parent
e1666d8e9a
commit
59ffa3a1e5
@ -13,12 +13,18 @@
|
|||||||
" If you want to use airline's statusline, just disable this layer
|
" If you want to use airline's statusline, just disable this layer
|
||||||
" >
|
" >
|
||||||
" [[layers]]
|
" [[layers]]
|
||||||
" name = "core#statusline"
|
" name = 'core#statusline'
|
||||||
" enable = false
|
" enable = false
|
||||||
" <
|
" <
|
||||||
|
|
||||||
scriptencoding utf-8
|
scriptencoding utf-8
|
||||||
|
|
||||||
|
if exists('g:_spacevim_statusline_loaded')
|
||||||
|
finish
|
||||||
|
endif
|
||||||
|
|
||||||
let g:_spacevim_statusline_loaded = 1
|
let g:_spacevim_statusline_loaded = 1
|
||||||
|
|
||||||
" APIs
|
" APIs
|
||||||
let s:MESSLETTERS = SpaceVim#api#import('messletters')
|
let s:MESSLETTERS = SpaceVim#api#import('messletters')
|
||||||
let s:TIME = SpaceVim#api#import('time')
|
let s:TIME = SpaceVim#api#import('time')
|
||||||
@ -98,9 +104,6 @@ let s:loaded_sections = ['syntax checking', 'major mode', 'minor mode lighters',
|
|||||||
let s:loaded_sections_r = g:spacevim_statusline_right_sections
|
let s:loaded_sections_r = g:spacevim_statusline_right_sections
|
||||||
let s:loaded_sections_l = g:spacevim_statusline_left_sections
|
let s:loaded_sections_l = g:spacevim_statusline_left_sections
|
||||||
|
|
||||||
let [s:lsep , s:rsep] = get(s:separators, g:spacevim_statusline_separator, s:separators['arrow'])
|
|
||||||
let [s:ilsep , s:irsep] = get(s:i_separators, g:spacevim_statusline_iseparator, s:i_separators['arrow'])
|
|
||||||
|
|
||||||
if SpaceVim#layers#isLoaded('checkers')
|
if SpaceVim#layers#isLoaded('checkers')
|
||||||
call add(s:loaded_modes, 'syntax-checking')
|
call add(s:loaded_modes, 'syntax-checking')
|
||||||
endif
|
endif
|
||||||
@ -389,9 +392,11 @@ function! SpaceVim#layers#core#statusline#get(...) abort
|
|||||||
\ . '%#SpaceVim_statusline_b#'
|
\ . '%#SpaceVim_statusline_b#'
|
||||||
\ . ' QuickFix %#SpaceVim_statusline_b_SpaceVim_statusline_c#'
|
\ . ' QuickFix %#SpaceVim_statusline_b_SpaceVim_statusline_c#'
|
||||||
\ . s:lsep
|
\ . s:lsep
|
||||||
\ . ( has('patch-8.0.1384') ? ((getqflist({'title' : 0}).title ==# ':setqflist()') ? '' :
|
\ . ( has('patch-8.0.1384')
|
||||||
|
\ ? ((getqflist({'title' : 0}).title ==# ':setqflist()') ? '' :
|
||||||
\ '%#SpaceVim_statusline_c#'
|
\ '%#SpaceVim_statusline_c#'
|
||||||
\ . getqflist({'title' : 0}).title . '%#SpaceVim_statusline_c_SpaceVim_statusline_z#' . s:lsep
|
\ . getqflist({'title' : 0}).title
|
||||||
|
\ . '%#SpaceVim_statusline_c_SpaceVim_statusline_z#' . s:lsep
|
||||||
\ ) : '')
|
\ ) : '')
|
||||||
else
|
else
|
||||||
return '%#SpaceVim_statusline_ia#'
|
return '%#SpaceVim_statusline_ia#'
|
||||||
@ -400,15 +405,22 @@ function! SpaceVim#layers#core#statusline#get(...) abort
|
|||||||
\ . '%#SpaceVim_statusline_b#'
|
\ . '%#SpaceVim_statusline_b#'
|
||||||
\ . ' Location List %#SpaceVim_statusline_b_SpaceVim_statusline_c#'
|
\ . ' Location List %#SpaceVim_statusline_b_SpaceVim_statusline_c#'
|
||||||
\ . s:lsep
|
\ . s:lsep
|
||||||
\ . ( has('patch-8.0.1384') ? ((getloclist(winnr(),{'title' : 0}).title ==# ':setloclist()') ? '' :
|
\ . ( has('patch-8.0.1384')
|
||||||
|
\ ? ((getloclist(winnr(),{'title' : 0}).title ==# ':setloclist()')
|
||||||
|
\ ? '' :
|
||||||
\ '%#SpaceVim_statusline_c#'
|
\ '%#SpaceVim_statusline_c#'
|
||||||
\ . getloclist(winnr(),{'title' : 0}).title . '%#SpaceVim_statusline_c_SpaceVim_statusline_z#' . s:lsep
|
\ . getloclist(winnr(),{'title' : 0}).title
|
||||||
|
\ . '%#SpaceVim_statusline_c_SpaceVim_statusline_z#' . s:lsep
|
||||||
\ ) : '')
|
\ ) : '')
|
||||||
|
|
||||||
endif
|
endif
|
||||||
elseif &filetype ==# 'defx'
|
elseif &filetype ==# 'defx'
|
||||||
return '%#SpaceVim_statusline_ia#' . s:winnr(1) . '%#SpaceVim_statusline_ia_SpaceVim_statusline_b#' . s:lsep
|
return '%#SpaceVim_statusline_ia#' . s:winnr(1)
|
||||||
\ . '%#SpaceVim_statusline_b# defx %#SpaceVim_statusline_b_SpaceVim_statusline_c#' . s:lsep . ' '
|
\ . '%#SpaceVim_statusline_ia_SpaceVim_statusline_b#' . s:lsep
|
||||||
|
\ . '%#SpaceVim_statusline_b#'
|
||||||
|
\ . ' defx '
|
||||||
|
\ . '%#SpaceVim_statusline_b_SpaceVim_statusline_c#'
|
||||||
|
\ . s:lsep . ' '
|
||||||
elseif &filetype ==# 'Fuzzy'
|
elseif &filetype ==# 'Fuzzy'
|
||||||
return '%#SpaceVim_statusline_a_bold# Fuzzy %#SpaceVim_statusline_a_SpaceVim_statusline_b#' . s:lsep
|
return '%#SpaceVim_statusline_a_bold# Fuzzy %#SpaceVim_statusline_a_SpaceVim_statusline_b#' . s:lsep
|
||||||
\ . '%#SpaceVim_statusline_b# %{fuzzy#statusline()} %#SpaceVim_statusline_b_SpaceVim_statusline_c#' . s:lsep
|
\ . '%#SpaceVim_statusline_b# %{fuzzy#statusline()} %#SpaceVim_statusline_b_SpaceVim_statusline_c#' . s:lsep
|
||||||
@ -519,7 +531,10 @@ function! SpaceVim#layers#core#statusline#get(...) abort
|
|||||||
\ . '%#SpaceVim_statusline_z#%=%#SpaceVim_statusline_c_SpaceVim_statusline_z#' . s:rsep
|
\ . '%#SpaceVim_statusline_z#%=%#SpaceVim_statusline_c_SpaceVim_statusline_z#' . s:rsep
|
||||||
\ . '%#SpaceVim_statusline_c# %{SpaceVim#layers#core#statusline#denite_status("path") . SpaceVim#layers#core#statusline#denite_status("linenr")}'
|
\ . '%#SpaceVim_statusline_c# %{SpaceVim#layers#core#statusline#denite_status("path") . SpaceVim#layers#core#statusline#denite_status("linenr")}'
|
||||||
elseif &filetype ==# 'denite-filter'
|
elseif &filetype ==# 'denite-filter'
|
||||||
return '%#SpaceVim_statusline_a_bold# Filter %#SpaceVim_statusline_a_SpaceVim_statusline_b#'
|
return '%#SpaceVim_statusline_a_bold#'
|
||||||
|
\ . ' Filter '
|
||||||
|
\ . '%#SpaceVim_statusline_a_SpaceVim_statusline_b#'
|
||||||
|
\ . s:lsep
|
||||||
elseif &filetype ==# 'unite'
|
elseif &filetype ==# 'unite'
|
||||||
return '%#SpaceVim_statusline_a_bold#%{SpaceVim#layers#core#statusline#unite_mode()} Unite '
|
return '%#SpaceVim_statusline_a_bold#%{SpaceVim#layers#core#statusline#unite_mode()} Unite '
|
||||||
\ . '%#SpaceVim_statusline_a_bold_SpaceVim_statusline_b#' . s:lsep . ' %{get(unite#get_context(), "buffer_name", "")} '
|
\ . '%#SpaceVim_statusline_a_bold_SpaceVim_statusline_b#' . s:lsep . ' %{get(unite#get_context(), "buffer_name", "")} '
|
||||||
@ -539,9 +554,17 @@ function! SpaceVim#layers#core#statusline#get(...) abort
|
|||||||
elseif &filetype ==# 'SpaceVimRunner'
|
elseif &filetype ==# 'SpaceVimRunner'
|
||||||
return '%#SpaceVim_statusline_a# Runner %#SpaceVim_statusline_a_SpaceVim_statusline_b# %{SpaceVim#plugins#runner#status()}'
|
return '%#SpaceVim_statusline_a# Runner %#SpaceVim_statusline_a_SpaceVim_statusline_b# %{SpaceVim#plugins#runner#status()}'
|
||||||
elseif &filetype ==# 'SpaceVimREPL'
|
elseif &filetype ==# 'SpaceVimREPL'
|
||||||
return '%#SpaceVim_statusline_a# REPL %#SpaceVim_statusline_a_SpaceVim_statusline_b# %{SpaceVim#plugins#repl#status()}'
|
return '%#SpaceVim_statusline_a#'
|
||||||
|
\ . ' REPL '
|
||||||
|
\ . '%#SpaceVim_statusline_a_SpaceVim_statusline_b#'
|
||||||
|
\ . s:lsep
|
||||||
|
\ . ' %{SpaceVim#plugins#repl#status()}'
|
||||||
elseif &filetype ==# 'VimMailClient'
|
elseif &filetype ==# 'VimMailClient'
|
||||||
return '%#SpaceVim_statusline_a# VimMail %#SpaceVim_statusline_a_SpaceVim_statusline_b# %{mail#client#win#status().dir}'
|
return '%#SpaceVim_statusline_a#'
|
||||||
|
\ . ' VimMail '
|
||||||
|
\ . '%#SpaceVim_statusline_a_SpaceVim_statusline_b#'
|
||||||
|
\ . s:lsep
|
||||||
|
\ . ' %{mail#client#win#status().dir}'
|
||||||
elseif &filetype ==# 'SpaceVimQuickFix'
|
elseif &filetype ==# 'SpaceVimQuickFix'
|
||||||
return '%#SpaceVim_statusline_a# SpaceVimQuickFix %#SpaceVim_statusline_a_SpaceVim_statusline_b#'
|
return '%#SpaceVim_statusline_a# SpaceVimQuickFix %#SpaceVim_statusline_a_SpaceVim_statusline_b#'
|
||||||
elseif &filetype ==# 'VebuggerShell'
|
elseif &filetype ==# 'VebuggerShell'
|
||||||
@ -715,6 +738,9 @@ function! SpaceVim#layers#core#statusline#rsep() abort
|
|||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
function! SpaceVim#layers#core#statusline#config() abort
|
function! SpaceVim#layers#core#statusline#config() abort
|
||||||
|
let [s:lsep , s:rsep] = get(s:separators, g:spacevim_statusline_separator, s:separators['arrow'])
|
||||||
|
let [s:ilsep , s:irsep] = get(s:i_separators, g:spacevim_statusline_iseparator, s:i_separators['arrow'])
|
||||||
|
|
||||||
call SpaceVim#mapping#space#def('nnoremap', ['t', 'm', 'm'], 'call SpaceVim#layers#core#statusline#toggle_section("minor mode lighters")',
|
call SpaceVim#mapping#space#def('nnoremap', ['t', 'm', 'm'], 'call SpaceVim#layers#core#statusline#toggle_section("minor mode lighters")',
|
||||||
\ 'toggle the minor mode lighters', 1)
|
\ 'toggle the minor mode lighters', 1)
|
||||||
call SpaceVim#mapping#space#def('nnoremap', ['t', 'm', 'M'], 'call SpaceVim#layers#core#statusline#toggle_section("major mode")',
|
call SpaceVim#mapping#space#def('nnoremap', ['t', 'm', 'M'], 'call SpaceVim#layers#core#statusline#toggle_section("major mode")',
|
||||||
|
@ -188,6 +188,7 @@ function! SpaceVim#layers#core#tabline#get() abort
|
|||||||
endfor
|
endfor
|
||||||
endif
|
endif
|
||||||
endif
|
endif
|
||||||
|
" get the list of displayed items
|
||||||
let s:shown_items = shown_items
|
let s:shown_items = shown_items
|
||||||
if empty(shown_items)
|
if empty(shown_items)
|
||||||
return ''
|
return ''
|
||||||
@ -214,7 +215,7 @@ function! SpaceVim#layers#core#tabline#get() abort
|
|||||||
if right_hidden_tab_number > 0
|
if right_hidden_tab_number > 0
|
||||||
let t .= ' %#SpaceVim_tabline_a_SpaceVim_tabline_b#' . s:lsep
|
let t .= ' %#SpaceVim_tabline_a_SpaceVim_tabline_b#' . s:lsep
|
||||||
endif
|
endif
|
||||||
let t .= '%#SpaceVim_tabline_b# '
|
let t .= s:is_modified(shown_items[0].bufnr) ? '%#SpaceVim_tabline_m_i# ' : '%#SpaceVim_tabline_b# '
|
||||||
endif
|
endif
|
||||||
let index = 1
|
let index = 1
|
||||||
for item in shown_items[:-2]
|
for item in shown_items[:-2]
|
||||||
@ -222,14 +223,25 @@ function! SpaceVim#layers#core#tabline#get() abort
|
|||||||
let t .= '%' . index . '@SpaceVim#layers#core#tabline#jump@'
|
let t .= '%' . index . '@SpaceVim#layers#core#tabline#jump@'
|
||||||
endif
|
endif
|
||||||
let t .= s:wrap_id(index)
|
let t .= s:wrap_id(index)
|
||||||
let index += 1
|
|
||||||
let t .= s:get_no_empty(gettabvar(item.tabnr, '_spacevim_tab_name'), item.bufname)
|
let t .= s:get_no_empty(gettabvar(item.tabnr, '_spacevim_tab_name'), item.bufname)
|
||||||
if item.tabnr == current_tabnr - 1
|
let index += 1
|
||||||
let t .= ' %#SpaceVim_tabline_b_SpaceVim_tabline_a#' . s:lsep . '%#SpaceVim_tabline_a# '
|
if item.tabnr == current_tabnr
|
||||||
elseif item.tabnr == current_tabnr
|
if s:is_modified(item.bufnr)
|
||||||
let t .= ' %#SpaceVim_tabline_a_SpaceVim_tabline_b#' . s:lsep . '%#SpaceVim_tabline_b# '
|
let t .= ' %#SpaceVim_tabline_m_SpaceVim_tabline_b#' . s:lsep
|
||||||
else
|
else
|
||||||
let t .= ' ' . s:ilsep . ' '
|
let t .= ' %#SpaceVim_tabline_a_SpaceVim_tabline_b#' . s:lsep
|
||||||
|
endif
|
||||||
|
let t .= s:is_modified(shown_items[index-1].bufnr) ? '%#SpaceVim_tabline_m_i# ' : '%#SpaceVim_tabline_b# '
|
||||||
|
elseif item.tabnr == current_tabnr - 1
|
||||||
|
" check if current_tabnr is modified
|
||||||
|
if s:is_modified(s:BUFFER.bufnr())
|
||||||
|
let t .= ' %#SpaceVim_tabline_b_SpaceVim_tabline_m#' . s:lsep . '%#SpaceVim_tabline_m# '
|
||||||
|
else
|
||||||
|
let t .= ' %#SpaceVim_tabline_b_SpaceVim_tabline_a#' . s:lsep . '%#SpaceVim_tabline_a# '
|
||||||
|
endif
|
||||||
|
else
|
||||||
|
let t .= s:is_modified(shown_items[index-1].bufnr) ? '%#SpaceVim_tabline_m_i# ' : '%#SpaceVim_tabline_b# '
|
||||||
|
let t .= s:ilsep . ' '
|
||||||
endif
|
endif
|
||||||
endfor
|
endfor
|
||||||
let item = shown_items[-1]
|
let item = shown_items[-1]
|
||||||
|
@ -1427,7 +1427,7 @@ This layer provides default statusline for SpaceVim If you want to use
|
|||||||
airline's statusline, just disable this layer
|
airline's statusline, just disable this layer
|
||||||
>
|
>
|
||||||
[[layers]]
|
[[layers]]
|
||||||
name = "core#statusline"
|
name = 'core#statusline'
|
||||||
enable = false
|
enable = false
|
||||||
<
|
<
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user