vim: housekeeping

This commit is contained in:
Michael Grote 2023-11-15 08:59:16 +01:00
parent 1ec4eefb18
commit 09d05fa0a0

97
.vimrc
View file

@ -12,32 +12,26 @@ Plugin 'preservim/nerdtree'
Plugin 'pearofducks/ansible-vim' Plugin 'pearofducks/ansible-vim'
" omnicompletion während dem tippen " omnicompletion während dem tippen
Plugin 'vim-scripts/AutoComplPop' Plugin 'vim-scripts/AutoComplPop'
" statusline
Plugin 'itchyny/lightline.vim'
" languagepack " languagepack
Plugin 'sheerun/vim-polyglot' Plugin 'sheerun/vim-polyglot'
" highlight fuer movement mit tTfFwW " highlight fuer movement mit tTfFwW
Plugin 'unblevable/quick-scope' Plugin 'unblevable/quick-scope'
" fuzzy finder " fuzzy finder
Plugin 'ctrlpvim/ctrlp.vim' Plugin 'ctrlpvim/ctrlp.vim'
" Shellcheck Integration
Plugin 'itspriddle/vim-shellcheck'
" git integration G: " git integration G:
Plugin 'tpope/vim-fugitive' Plugin 'tpope/vim-fugitive'
" statusline
Plugin 'itchyny/lightline.vim'
" ausrichten von text " ausrichten von text
Plugin 'junegunn/vim-easy-align' Plugin 'junegunn/vim-easy-align'
" buffer in tabline " buffer in tabline
Plugin 'ap/vim-buftabline' Plugin 'ap/vim-buftabline'
" start screen " start screen
Plugin 'mhinz/vim-startify' Plugin 'mhinz/vim-startify'
" bracketed paste/ keine set-paste mehr " bracketed paste/ kein set-paste mehr
Plugin 'ConradIrwin/vim-bracketed-paste' Plugin 'ConradIrwin/vim-bracketed-paste'
" bessere textoperatroren
Plugin 'wellle/targets.vim'
" Undotree " Undotree
Plugin 'mbbill/undotree' Plugin 'mbbill/undotree'
" vim as MANPAGER
Plugin 'lambdalisue/vim-manpager'
" highlight yanked text " highlight yanked text
Plugin 'machakann/vim-highlightedyank' Plugin 'machakann/vim-highlightedyank'
call vundle#end() call vundle#end()
@ -64,13 +58,11 @@ set ignorecase
" Override the 'ignorecase' option if the search pattern contains upper case characters. " Override the 'ignorecase' option if the search pattern contains upper case characters.
set smartcase set smartcase
" show status-bar
set laststatus=2
" Show line numbers. " Show line numbers.
set number set number
" setze cursorline
"set cursorline
"highlight CursorLine cterm=NONE ctermbg=green ctermfg=white guibg=darkred guifg=white
" ### Kommandovervollständigung " ### Kommandovervollständigung
" https://www.reddit.com/r/vim/comments/oo9gms/any_way_to_get_vim_to_not_defaulting_to_the_first/h5wygix/?context=8&depth=9 " https://www.reddit.com/r/vim/comments/oo9gms/any_way_to_get_vim_to_not_defaulting_to_the_first/h5wygix/?context=8&depth=9
set wildmode=longest,list,full set wildmode=longest,list,full
@ -94,7 +86,7 @@ set nowrap
set wrap linebreak set wrap linebreak
" Enable syntax highlighting " Enable syntax highlighting
syntax on syntax on
" aktiviere maus nur im normalmode " aktiviere maus
set mouse=a set mouse=a
" vergrößere/verkleinere splits mit der maus " vergrößere/verkleinere splits mit der maus
" https://vi.stackexchange.com/questions/514/how-do-i-change-the-current-splits-width-and-height " https://vi.stackexchange.com/questions/514/how-do-i-change-the-current-splits-width-and-height
@ -117,11 +109,6 @@ set wildignore+=*/tmp/*,*.so,*.swp,*.zip " MacOSX/Linux
set wildignore+=*\\tmp\\*,*.swp,*.zip,*.exe " Windows set wildignore+=*\\tmp\\*,*.swp,*.zip,*.exe " Windows
let g:ctrlp_custom_ignore = '\v[\/]\.(git|hg|svn)$' let g:ctrlp_custom_ignore = '\v[\/]\.(git|hg|svn)$'
let g:ctrlp_map = '' let g:ctrlp_map = ''
let g:ctrlp_extensions = ['line', 'undo']
" ### shellcheck
" farbe für zeilenmarkierung im quickfix-windows
hi QuickFixLine ctermbg=black guibg=black
" ### lightline/statusline " ### lightline/statusline
" blende insert/visual/... in der commandline aus, steht in lightline " blende insert/visual/... in der commandline aus, steht in lightline
@ -141,29 +128,29 @@ let g:lightline = {
" returns all modified files of the current git repo " returns all modified files of the current git repo
" `2>/dev/null` makes the command fail quietly, so that when we are not " `2>/dev/null` makes the command fail quietly, so that when we are not
" in a git repo, the list will be empty " in a git repo, the list will be empty
function! s:gitModified() function! s:gitmodified()
let files = systemlist('git ls-files -m 2>/dev/null') let files = systemlist('git ls-files -m 2>/dev/null')
return map(files, "{'line': v:val, 'path': v:val}") return map(files, "{'line': v:val, 'path': v:val}")
endfunction endfunction
" same as above, but show untracked files, honouring .gitignore " same as above, but show untracked files, honouring .gitignore
function! s:gitUntracked() function! s:gituntracked()
let files = systemlist('git ls-files -o --exclude-standard 2>/dev/null') let files = systemlist('git ls-files -o --exclude-standard 2>/dev/null')
return map(files, "{'line': v:val, 'path': v:val}") return map(files, "{'line': v:val, 'path': v:val}")
endfunction endfunction
let g:startify_lists = [ let g:startify_lists = [
\ { 'type': 'files', 'header': [' MRU'] }, \ { 'type': 'files', 'header': [' mru'] },
\ { 'type': 'dir', 'header': [' MRU '. getcwd()] }, \ { 'type': 'dir', 'header': [' mru '. getcwd()] },
\ { 'type': 'sessions', 'header': [' Sessions'] }, \ { 'type': 'sessions', 'header': [' sessions'] },
\ { 'type': 'bookmarks', 'header': [' Bookmarks'] }, \ { 'type': 'bookmarks', 'header': [' bookmarks'] },
\ { 'type': function('s:gitModified'), 'header': [' git modified']}, \ { 'type': function('s:gitmodified'), 'header': [' git modified']},
\ { 'type': function('s:gitUntracked'), 'header': [' git untracked']}, \ { 'type': function('s:gituntracked'), 'header': [' git untracked']},
\ { 'type': 'commands', 'header': [' Commands'] }, \ { 'type': 'commands', 'header': [' commands'] },
\ ] \ ]
" ### quick-scope " ### quick-scope
" Trigger a highlight in the appropriate direction only when pressing these keys: " trigger a highlight in the appropriate direction only when pressing these keys:
let g:qs_highlight_on_keys = ['f', 'F', 't', 'T'] let g:qs_highlight_on_keys = ['f', 'F', 't', 'T']
" wrap words with `` " wrap words with ``
@ -182,23 +169,8 @@ nnoremap <C-s> :w<CR>
nnoremap <C-j> :bnext<CR> nnoremap <C-j> :bnext<CR>
nnoremap <C-k> :bprev<CR> nnoremap <C-k> :bprev<CR>
" Saner CTRL-L
" https://github.com/mhinz/vim-galore#saner-ctrl-l
nnoremap <Leader>dh :nohlsearch<cr>:diffupdate<cr>:syntax sync fromstart<cr><c-l>
" toggle cursorline
nnoremap <Leader>h :set nocursorline!<CR>
" strg+f sucht fuzzy nach dateien " strg+f sucht fuzzy nach dateien
nnoremap <C-f> :CtrlP<CR> nnoremap <C-f> :CtrlP<CR>
" strg+l sucht fuzzy in Zeilen des aktuellen Buffers
nnoremap <C-l> :CtrlPLine<CR>
" mit , + n/p wechsele den Eintrag im Quickfix-Windows vor/zurück
" mit , c Öffne ShellCheck im Quickfix Windows
nnoremap cn :cn<CR>
nnoremap cp :cp<CR>
nnoremap <Leader>sc :ShellCheck!<CR>
" format paragraphs as markdown table " format paragraphs as markdown table
nnoremap <Leader>mm Vap:EasyAlign *\|<cr><esc> nnoremap <Leader>mm Vap:EasyAlign *\|<cr><esc>
@ -207,29 +179,11 @@ nnoremap <F7> Vap:EasyAlign *\|<cr><esc>
" lasse Y wie C oder D funktionieren " lasse Y wie C oder D funktionieren
nmap Y y$ nmap Y y$
" https://www.reddit.com/r/vim/comments/s1he17/is_there_a_plugin_that_makes_searching_and
nnoremap <Leader>sr :%s/<C-r><C-w>//gc<Left><Left><Left>
vnoremap <Leader>sr y:%s/<C-R>"//gc<Left><Left><Left>
" Toggle NERDTree " Toggle NERDTree
nnoremap <F2> :call ToggleNERDTreeFind()<CR> nnoremap <F2> :call ToggleNERDTreeFind()<CR>
"
" toddle Undotree " toddle Undotree
nnoremap <F6> :UndotreeToggle<CR> nnoremap <F6> :UndotreeToggle<CR>
nnoremap <Leader>u :UndotreeToggle<CR>
" besseres undo
" https://www.reddit.com/r/vim/comments/13gk0nl/is_there_a_way_to_make_undo_sensible/
" create undo points when
" typing these keys
" inoremap , ,<c-g>u
" inoremap . .<c-g>u
" inoremap ( (<c-g>u
" inoremap [ [<c-g>u
" inoremap = =<c-g>u
" inoremap \" \"<c-g>u
" inoremap <space> <space><c-g>u
" inoremap <CR> <CR><c-g>u
" U als un-undo und nicht als Großschreibung " U als un-undo und nicht als Großschreibung
nnoremap U :redo<Enter> nnoremap U :redo<Enter>
@ -239,14 +193,7 @@ iabbrev ncicht nicht
iabbrev nciht nicht iabbrev nciht nicht
" linenumbers " linenumbers
nnoremap <Leader>z :set nonumber! norelativenumber!<CR> nnoremap <Leader>z :set nonumber! <CR>
" https://jeffkreeftmeijer.com/vim-number/
:augroup numbertoggle
: autocmd!
: autocmd BufEnter,FocusGained,InsertLeave,WinEnter * if &nu && mode() != "i" | set rnu | endif
: autocmd BufLeave,FocusLost,InsertEnter,WinLeave * if &nu | set nornu | endif
:augroup END
" einzelne Aufräumfunktionen, bei F9 werden alle gecalled " einzelne Aufräumfunktionen, bei F9 werden alle gecalled
" trailing whitespaces werden automatisch beim speichern entfernt " trailing whitespaces werden automatisch beim speichern entfernt
@ -276,13 +223,6 @@ nnoremap <F9> :call Whitespaces_all()<CR>
" entferne trailing whitespaces beim speichern " entferne trailing whitespaces beim speichern
autocmd BufWritePre * :call Whitespaces_trailing() autocmd BufWritePre * :call Whitespaces_trailing()
" fix indentation/auto formatting
function! Fix_indentation()
if filetype ==# 'yaml' || filetype ==# 'bash'
autocmd BufWritePre * :normal gg=G
endif
endfunction
" Exit Vim if NERDTree is the only window remaining in the only tab. " Exit Vim if NERDTree is the only window remaining in the only tab.
autocmd BufEnter * if tabpagenr('$') == 1 && winnr('$') == 1 && exists('b:NERDTree') && b:NERDTree.isTabTree() | quit | endif autocmd BufEnter * if tabpagenr('$') == 1 && winnr('$') == 1 && exists('b:NERDTree') && b:NERDTree.isTabTree() | quit | endif
" NERDTree - show hidden files " NERDTree - show hidden files
@ -301,3 +241,4 @@ endfunction
" yaml einrückung " yaml einrückung
autocmd FileType yaml setlocal ai ts=2 sw=2 et autocmd FileType yaml setlocal ai ts=2 sw=2 et
autocmd FileType yml setlocal ai ts=2 sw=2 et autocmd FileType yml setlocal ai ts=2 sw=2 et