From da0062e1fed43eb6fee2efeba76a9d0a7fb5d413 Mon Sep 17 00:00:00 2001 From: mg Date: Thu, 7 Oct 2021 10:08:51 +0200 Subject: [PATCH] vim: statusline2 (#1) Co-authored-by: Michael Grote Reviewed-on: https://git.mgrote.net/mg/dotfiles/pulls/1 Co-authored-by: mg Co-committed-by: mg --- .vimrc | 78 ++++++++++++++++++++++++++++++++++++++++++++-------------- 1 file changed, 60 insertions(+), 18 deletions(-) diff --git a/.vimrc b/.vimrc index 28dabbf..402bcab 100644 --- a/.vimrc +++ b/.vimrc @@ -6,8 +6,6 @@ set rtp+=~/.vim/bundle/Vundle.vim call vundle#begin('~/.vim/plugged') " Let Vundle manage Vundle; muss immer der erste Eintrag sein Plugin 'VundleVim/Vundle.vim' -" statusline -Plugin 'itchyny/lightline.vim' " languagepack Plugin 'sheerun/vim-polyglot' " fuzzy finder @@ -70,20 +68,6 @@ set clipboard=unnamedplus set showmatch " ### Plugins" -" ### lightline/statusline -" blende insert/visual/... in der commandline aus, steht in lightline -set noshowmode -set laststatus=2 -let g:lightline = { - \ 'active': { - \ 'left': [ [ 'mode', 'paste' ], - \ [ 'gitbranch', 'readonly', 'filename', 'modified' ] ] - \ }, - \ 'component_function': { - \ 'gitbranch': 'FugitiveHead' - \ }, - \ } - " ### ripgrep und ctrlp " sudo apt install ripgrep(rg) if executable('rg') @@ -101,9 +85,9 @@ let g:ctrlp_custom_ignore = '\v[\/]\.(git|hg|svn)$' " stelle standard keybinding um let g:ctrlp_map = '' - - " ### Keybindings +" deaktiviere Ex-Mode keybinding +:nnoremap Q " Ctrl+S zum speichern nmap :w " ctrl+W zum schließen @@ -119,3 +103,61 @@ nmap :tab G " markiere text im visual mode; suche dann danach mit // im visual-mode " https://vim.fandom.com/wiki/Search_for_visually_selected_text vnoremap // y/\V=escape(@",'/\') +" https://shapeshed.com/vim-statuslines/ +function! GitBranch() + return system("git rev-parse --abbrev-ref HEAD 2>/dev/null | tr -d '\n'") +endfunction + +### Statuszeile +" https://stackoverflow.com/questions/56274737/what-is-the-return-value-for-visual-block-mode-in-vimscript +" https://jdhao.github.io/2019/11/03/vim_custom_statusline/ +" https://shapeshed.com/vim-statuslines/ +" https://jip.dev/posts/a-simpler-vim-statusline/ +" https://jordanelver.co.uk/blog/2015/05/27/working-with-vim-colorschemes/ +" blende insert/visual/... in der commandline aus, steht in lightline +set noshowmode +set laststatus=2 + +" Funktion git branch +function! StatuslineGit() + let l:branchname = GitBranch() + return strlen(l:branchname) > 0?' '.l:branchname.' ':'' +endfunction + +set statusline= +set statusline+=%#StatusLineTerm# +set statusline+=%{g:currentmode[mode()]} +set statusline+=%#PmenuSel# +set statusline+=%{StatuslineGit()} +set statusline+=%#ToolButton# +set statusline+=\%f +set statusline+=%#TabLineFill# +set statusline+=%m +set statusline+=%= +set statusline+=\ %y +set statusline+=\ %{&fileencoding?&fileencoding:&encoding} +set statusline+=\ [%{&fileformat}\] +set statusline+=\ %l:%c +set statusline+=\ +set statusline+=%{&paste?'PASTE':''} +let g:currentmode={ + \ 'n' : 'NORMAL', + \ 'no' : 'NORMAL·OPERATOR PENDING', + \ 'v' : 'VISUAL', + \ 'V' : 'VISUAL·LINE', + \ "\" : 'VISUAL·BLOCK', + \ 's' : 'SELECT', + \ 'S' : 'SELECT·LINE', + \ 'x19' : 'SELECT-BLOCK', + \ 'i' : 'INSERT', + \ 'R' : 'REPLACE', + \ 'Rv' : 'VISUAL·REPLACE', + \ 'c' : 'COMMAND', + \ 'cv' : 'VIM EX', + \ 'ce' : 'EX', + \ 'r' : 'PROMPT', + \ 'rm' : 'MORE ', + \ 'r?' : 'CONFIRM ', + \ '!' : 'SHELL ', + \ 't' : 'TERMINAL ' + \}