mirror of
https://github.com/SpaceVim/SpaceVim.git
synced 2025-04-13 14:59:10 +08:00
Add tabline layer
This commit is contained in:
parent
6ef8bc1d92
commit
bf0df72889
0
autoload/SpaceVim/layers/core/banner.vim
Normal file
0
autoload/SpaceVim/layers/core/banner.vim
Normal file
41
autoload/SpaceVim/layers/core/statusline.vim
Normal file
41
autoload/SpaceVim/layers/core/statusline.vim
Normal file
@ -0,0 +1,41 @@
|
||||
let g:spacevim_statusline_mode_format = {
|
||||
\ 'n' : 'NORMAL',
|
||||
\ 'i' : 'INSERT',
|
||||
\ 'v' : 'VISUAL',
|
||||
\ }
|
||||
|
||||
"""""""""""""""""""""""""""""""""
|
||||
|
||||
function! s:mode() abort
|
||||
let mt = g:spacevim_statusline_mode_format
|
||||
let m = mode()
|
||||
return mt[m]
|
||||
endfunction
|
||||
|
||||
function! s:filetype() abort
|
||||
return &filetype
|
||||
endfunction
|
||||
|
||||
function! s:encoding() abort
|
||||
return &encoding
|
||||
endfunction
|
||||
|
||||
|
||||
function! s:tabname() abort
|
||||
return '1'
|
||||
endfunction
|
||||
|
||||
function! SpaceVim#layers#core#statusline#get() abort
|
||||
return join([
|
||||
\ s:mode(),
|
||||
\ s:tabname(),
|
||||
\ s:encoding(),
|
||||
\ s:filetype()
|
||||
\ ], ' ')
|
||||
return s:mode() . s:tabname()
|
||||
endfunction
|
||||
|
||||
function! s:refresh() abort
|
||||
endfunction
|
||||
set statusline=%!SpaceVim#layers#core#statusline#get()
|
||||
|
59
autoload/SpaceVim/layers/core/tabline.vim
Normal file
59
autoload/SpaceVim/layers/core/tabline.vim
Normal file
@ -0,0 +1,59 @@
|
||||
"=============================================================================
|
||||
" tabline.vim --- core#tabline Layer file for SpaceVim
|
||||
" Copyright (c) 2012-2016 Shidong Wang & Contributors
|
||||
" Author: Shidong Wang < wsdjeg at 163.com >
|
||||
" URL: https://spacevim.org
|
||||
" License: MIT license
|
||||
"=============================================================================
|
||||
|
||||
""
|
||||
" @section core#tabline, layer-core-tabline
|
||||
" @parentsection layers
|
||||
" This layer provides default tabline for SpaceVim
|
||||
|
||||
let s:messletters = SpaceVim#api#import('messletters')
|
||||
let s:file = SpaceVim#api#import('file')
|
||||
|
||||
|
||||
function! s:tabname(id) abort
|
||||
let id = s:messletters.bubble_num(a:id, g:spacevim_buffer_index_type) . ' '
|
||||
let fn = fnamemodify(bufname(a:id), ':t')
|
||||
if g:spacevim_enable_tabline_filetype_icon
|
||||
let icon = s:file.fticon(fn)
|
||||
if !empty(icon)
|
||||
let fn = icon . ' ' . fn
|
||||
endif
|
||||
endif
|
||||
if empty(fn)
|
||||
return 'No Name'
|
||||
else
|
||||
return id . fn
|
||||
endif
|
||||
endfunction
|
||||
|
||||
function! SpaceVim#layers#core#tabline#get() abort
|
||||
let t = ' '
|
||||
let nr = tabpagenr()
|
||||
" if nr > 1
|
||||
for i in range(1, nr)
|
||||
let buflist = tabpagebuflist(i)
|
||||
let winnr = tabpagewinnr(i)
|
||||
let name = fnamemodify(bufname(buflist[winnr - 1]), ':t')
|
||||
let id = s:messletters.bubble_num(i, g:spacevim_buffer_index_type)
|
||||
let icon = s:file.fticon(name)
|
||||
if !empty(icon)
|
||||
let name = icon . ' ' . name
|
||||
endif
|
||||
let t .= id . ' ' . name
|
||||
if i == nr
|
||||
let t .= '%#TabLineSel#'
|
||||
else
|
||||
let t .= '%#TabLine# | '
|
||||
endif
|
||||
endfor
|
||||
let t .= '%#TabLineFill#%T'
|
||||
return t
|
||||
endfunction
|
||||
function! SpaceVim#layers#core#tabline#config() abort
|
||||
set tabline=%!SpaceVim#layers#core#tabline#get()
|
||||
endfunction
|
@ -24,22 +24,23 @@ CONTENTS *SpaceVim-contents*
|
||||
2. autocomplete..................................|SpaceVim-autocomplete|
|
||||
3. checkers....................................|SpaceVim-layer-checkers|
|
||||
4. colorscheme....................................|SpaceVim-colorscheme|
|
||||
5. exprfold....................................|SpaceVim-layer-exprfold|
|
||||
6. incsearch..................................|SpaceVim-layer-incsearch|
|
||||
7. indentmove................................|SpaceVim-layer-indentmove|
|
||||
8. lang#c........................................|SpaceVim-layer-lang-c|
|
||||
9. lang#elixir..............................|SpaceVim-layer-lang-elixir|
|
||||
10. lang#go.....................................|SpaceVim-layer-lang-go|
|
||||
11. lang#java.................................|SpaceVim-layer-lang-java|
|
||||
12. lang#ocaml...............................|SpaceVim-layer-lang-ocaml|
|
||||
13. lang#php...................................|SpaceVim-layer-lang-php|
|
||||
14. lang#puppet.............................|SpaceVim-layer-lang-puppet|
|
||||
15. lang#python.............................|SpaceVim-layer-lang-python|
|
||||
16. lang#rust.................................|SpaceVim-layer-lang-rust|
|
||||
17. lang#xml...................................|SpaceVim-layer-lang-xml|
|
||||
18. operator...................................|SpaceVim-layer-operator|
|
||||
19. shell.........................................|SpaceVim-layer-shell|
|
||||
20. tmux...........................................|SpaceVim-layer-tmux|
|
||||
5. core#tabline............................|SpaceVim-layer-core-tabline|
|
||||
6. exprfold....................................|SpaceVim-layer-exprfold|
|
||||
7. incsearch..................................|SpaceVim-layer-incsearch|
|
||||
8. indentmove................................|SpaceVim-layer-indentmove|
|
||||
9. lang#c........................................|SpaceVim-layer-lang-c|
|
||||
10. lang#elixir.............................|SpaceVim-layer-lang-elixir|
|
||||
11. lang#go.....................................|SpaceVim-layer-lang-go|
|
||||
12. lang#java.................................|SpaceVim-layer-lang-java|
|
||||
13. lang#ocaml...............................|SpaceVim-layer-lang-ocaml|
|
||||
14. lang#php...................................|SpaceVim-layer-lang-php|
|
||||
15. lang#puppet.............................|SpaceVim-layer-lang-puppet|
|
||||
16. lang#python.............................|SpaceVim-layer-lang-python|
|
||||
17. lang#rust.................................|SpaceVim-layer-lang-rust|
|
||||
18. lang#xml...................................|SpaceVim-layer-lang-xml|
|
||||
19. operator...................................|SpaceVim-layer-operator|
|
||||
20. shell.........................................|SpaceVim-layer-shell|
|
||||
21. tmux...........................................|SpaceVim-layer-tmux|
|
||||
5. FAQ........................................................|SpaceVim-faq|
|
||||
|
||||
==============================================================================
|
||||
@ -458,6 +459,11 @@ https://github.com/SpaceVim/SpaceVim/issues/209#issuecomment-280545818
|
||||
zellner
|
||||
<
|
||||
|
||||
==============================================================================
|
||||
CORE#TABLINE *SpaceVim-layer-core-tabline*
|
||||
|
||||
This layer provides default tabline for SpaceVim
|
||||
|
||||
==============================================================================
|
||||
EXPRFOLD *SpaceVim-layer-exprfold*
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user