From d9693483b4ae256c391cbffed8b329eb1b4d02ce Mon Sep 17 00:00:00 2001 From: Michael Grote Date: Mon, 31 May 2021 20:24:43 +0200 Subject: [PATCH] neue statusline --- .vimrc | 94 ++++++++++++++++++++++++++++++++++++++++++---------------- 1 file changed, 69 insertions(+), 25 deletions(-) diff --git a/.vimrc b/.vimrc index f7299a1..262922d 100644 --- a/.vimrc +++ b/.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 +:let mapleader = "," +" statusline +" https://www.tdaly.co.uk/projects/vim-statusline-generator/ +set laststatus=2 +set statusline= +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 set nocompatible filetype off @@ -54,7 +98,7 @@ Plugin 'jreybert/vimagit' call vundle#end() " " auto-pairs -let g:AutoPairsShortcutToggle = '' +let g:AutoPairsShortcutToggle = '' " Toogle Auto-Pairs mit Strg+P " zur Autovervollständigung von Klammern "