neue statusline
This commit is contained in:
parent
8c9e8aca5e
commit
d9693483b4
1 changed files with 69 additions and 25 deletions
90
.vimrc
90
.vimrc
|
@ -1,30 +1,74 @@
|
|||
" leader key
|
||||
:let mapleader = ","
|
||||
" vim statusline - kein plugin
|
||||
" https://shapeshed.com/vim-statuslines/
|
||||
function! GitBranch()
|
||||
return system("git rev-parse --abbrev-ref HEAD 2>/dev/null | tr -d '\n'")
|
||||
endfunction
|
||||
|
||||
function! StatuslineGit()
|
||||
let l:branchname = GitBranch()
|
||||
return strlen(l:branchname) > 0?' '.l:branchname.' ':''
|
||||
endfunction
|
||||
|
||||
" statusline
|
||||
" https://www.tdaly.co.uk/projects/vim-statusline-generator/
|
||||
set laststatus=2
|
||||
set statusline=
|
||||
set statusline+=%#PmenuSel#
|
||||
set statusline+=%{StatuslineGit()}
|
||||
set statusline+=%#LineNr#
|
||||
set statusline+=\ %f
|
||||
set statusline+=%m\
|
||||
set statusline+=%=
|
||||
set statusline+=%#CursorColumn#
|
||||
set statusline+=\ %y
|
||||
set statusline+=\ %{&fileencoding?&fileencoding:&encoding}
|
||||
set statusline+=\[%{&fileformat}\]
|
||||
set statusline+=\ %p%%
|
||||
set statusline+=\ %l:%c
|
||||
set statusline+=%{StatuslineMode()}
|
||||
set statusline+=\
|
||||
set statusline+=|
|
||||
set statusline+=\
|
||||
set statusline+=%F
|
||||
set statusline+=\
|
||||
set statusline+=|
|
||||
set statusline+=\
|
||||
set statusline+=%{b:gitbranch}
|
||||
set statusline+=%=
|
||||
set statusline+=%{strlen(&fenc)?&fenc:'none'}
|
||||
set statusline+=\
|
||||
set statusline+=|
|
||||
set statusline+=\
|
||||
set statusline+=%y
|
||||
set statusline+=\
|
||||
set statusline+=|
|
||||
set statusline+=\
|
||||
set statusline+=%{strftime(\"%H:%M\")}
|
||||
set statusline+=%9*
|
||||
set statusline+=%1*
|
||||
hi User9 ctermbg=black ctermfg=white guibg=black guifg=white
|
||||
hi User1 ctermbg=black ctermfg=darkgray guibg=black guifg=darkgray
|
||||
|
||||
function! StatuslineMode()
|
||||
let l:mode=mode()
|
||||
if l:mode==#"n"
|
||||
return "NORMAL"
|
||||
elseif l:mode==?"v"
|
||||
return "VISUAL"
|
||||
elseif l:mode==#"i"
|
||||
return "INSERT"
|
||||
elseif l:mode==#"R"
|
||||
return "REPLACE"
|
||||
elseif l:mode==?"s"
|
||||
return "SELECT"
|
||||
elseif l:mode==#"t"
|
||||
return "TERMINAL"
|
||||
elseif l:mode==#"c"
|
||||
return "COMMAND"
|
||||
elseif l:mode==#"!"
|
||||
return "SHELL"
|
||||
endif
|
||||
endfunction
|
||||
|
||||
function! StatuslineGitBranch()
|
||||
let b:gitbranch=""
|
||||
if &modifiable
|
||||
try
|
||||
let l:dir=expand('%:p:h')
|
||||
let l:gitrevparse = system("git -C ".l:dir." rev-parse --abbrev-ref HEAD")
|
||||
if !v:shell_error
|
||||
let b:gitbranch="(".substitute(l:gitrevparse, '\n', '', 'g').") "
|
||||
endif
|
||||
catch
|
||||
endtry
|
||||
endif
|
||||
endfunction
|
||||
|
||||
augroup GetGitBranch
|
||||
autocmd!
|
||||
autocmd VimEnter,WinEnter,BufEnter * call StatuslineGitBranch()
|
||||
augroup END
|
||||
|
||||
|
||||
" Vundle
|
||||
set nocompatible
|
||||
filetype off
|
||||
|
|
Loading…
Reference in a new issue