neue statusline

This commit is contained in:
Michael Grote 2021-05-31 20:24:43 +02:00
parent 8c9e8aca5e
commit d9693483b4

94
.vimrc
View file

@ -1,30 +1,74 @@
" leader key " leader key
:let mapleader = "," :let mapleader = ","
" vim statusline - kein plugin " statusline
" https://shapeshed.com/vim-statuslines/ " https://www.tdaly.co.uk/projects/vim-statusline-generator/
function! GitBranch() set laststatus=2
return system("git rev-parse --abbrev-ref HEAD 2>/dev/null | tr -d '\n'") set statusline=
endfunction 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
function! StatuslineGit()
let l:branchname = GitBranch()
return strlen(l:branchname) > 0?' '.l:branchname.' ':''
endfunction
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+=\
" Vundle " Vundle
set nocompatible set nocompatible
filetype off filetype off
@ -54,7 +98,7 @@ Plugin 'jreybert/vimagit'
call vundle#end() call vundle#end()
" "
" auto-pairs " auto-pairs
let g:AutoPairsShortcutToggle = '<C-P>' let g:AutoPairsShortcutToggle = '<C-P>'
" Toogle Auto-Pairs mit Strg+P " Toogle Auto-Pairs mit Strg+P
" zur Autovervollständigung von Klammern " zur Autovervollständigung von Klammern
" "