280 lines
8.4 KiB
VimL
280 lines
8.4 KiB
VimL
" Vundle
|
|
filetype off
|
|
" Set the runtime path to include Vundle and initialize
|
|
set rtp+=~/.vim/bundle/Vundle.vim
|
|
" Download plug-ins to the ~/.vim/plugged/ directory
|
|
call vundle#begin('~/.vim/plugged')
|
|
" Let Vundle manage Vundle; muss immer der erste Eintrag sein
|
|
Plugin 'VundleVim/Vundle.vim'
|
|
" project drawer
|
|
Plugin 'preservim/nerdtree'
|
|
" ansible integration
|
|
Plugin 'pearofducks/ansible-vim'
|
|
" omnicompletion während dem tippen
|
|
Plugin 'vim-scripts/AutoComplPop'
|
|
" languagepack
|
|
Plugin 'sheerun/vim-polyglot'
|
|
" highlight fuer movement mit tTfFwW
|
|
Plugin 'unblevable/quick-scope'
|
|
" fuzzy finder
|
|
Plugin 'ctrlpvim/ctrlp.vim'
|
|
" Shellcheck Integration
|
|
Plugin 'itspriddle/vim-shellcheck'
|
|
" git integration G:
|
|
Plugin 'tpope/vim-fugitive'
|
|
" statusline
|
|
Plugin 'itchyny/lightline.vim'
|
|
" ausrichten von text
|
|
Plugin 'junegunn/vim-easy-align'
|
|
" buffer in tabline
|
|
Plugin 'ap/vim-buftabline'
|
|
" start screen
|
|
Plugin 'mhinz/vim-startify'
|
|
" bracketed paste/ keine set-paste mehr
|
|
Plugin 'ConradIrwin/vim-bracketed-paste'
|
|
" bessere textoperatroren
|
|
Plugin 'wellle/targets.vim'
|
|
" Undotree
|
|
Plugin 'mbbill/undotree'
|
|
" vim as MANPAGER
|
|
Plugin 'lambdalisue/vim-manpager'
|
|
" highlight yanked text
|
|
Plugin 'machakann/vim-highlightedyank'
|
|
call vundle#end()
|
|
|
|
let mapleader = ","
|
|
|
|
" ### allgemeine Optionen
|
|
" ### Suche
|
|
" While typing a search command, show immediately where the so far typed pattern matches.
|
|
set incsearch
|
|
|
|
" When there is a previous search pattern, highlight all its matches.
|
|
set hlsearch
|
|
|
|
" Ignore case in search patterns.
|
|
set ignorecase
|
|
|
|
" Override the 'ignorecase' option if the search pattern contains upper case characters.
|
|
set smartcase
|
|
|
|
" Show line numbers.
|
|
set number
|
|
|
|
" setze cursorline
|
|
"set cursorline
|
|
"highlight CursorLine cterm=NONE ctermbg=green ctermfg=white guibg=darkred guifg=white
|
|
|
|
" ### 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
|
|
set wildmode=longest,list,full
|
|
set wildmenu
|
|
set wildignore=*.o,*~
|
|
|
|
" ### Rest
|
|
" Show (partial) command in status line.
|
|
set showcmd
|
|
set virtualedit=onemore
|
|
set encoding=UTF-8
|
|
set visualbell
|
|
set ruler
|
|
set undolevels=1000
|
|
set backspace=indent,eol,start
|
|
" ermögliche das bearbeitete buffer in der hintergrund können
|
|
set hidden
|
|
" verhindert zeilenumbrüche
|
|
set nowrap
|
|
" https://vim.fandom.com/wiki/Automatic_word_wrapping
|
|
set wrap linebreak
|
|
" Enable syntax highlighting
|
|
syntax on
|
|
" aktiviere maus nur im normalmode
|
|
set mouse=a
|
|
" https://unix.stackexchange.com/questions/12535/how-to-copy-text-from-vim-to-an-external-program
|
|
set clipboard=unnamedplus
|
|
" zeige "matching" klammer usw.
|
|
set showmatch
|
|
|
|
" ### Plugins
|
|
" ### ripgrep und ctrlp
|
|
if executable('rg')
|
|
let g:ctrlp_user_command = 'rg %s --files --hidden --color=never --glob ""'
|
|
else
|
|
let g:ctrlp_user_command = 'find %s -type f'
|
|
endif
|
|
" ignore files
|
|
" https://github.com/ctrlpvim/ctrlp.vim
|
|
set wildignore+=*/tmp/*,*.so,*.swp,*.zip " MacOSX/Linux
|
|
set wildignore+=*\\tmp\\*,*.swp,*.zip,*.exe " Windows
|
|
let g:ctrlp_custom_ignore = '\v[\/]\.(git|hg|svn)$'
|
|
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
|
|
" 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'
|
|
\ },
|
|
\ }
|
|
|
|
" ### vim startify
|
|
" returns all modified files of the current git repo
|
|
" `2>/dev/null` makes the command fail quietly, so that when we are not
|
|
" in a git repo, the list will be empty
|
|
function! s:gitModified()
|
|
let files = systemlist('git ls-files -m 2>/dev/null')
|
|
return map(files, "{'line': v:val, 'path': v:val}")
|
|
endfunction
|
|
|
|
" same as above, but show untracked files, honouring .gitignore
|
|
function! s:gitUntracked()
|
|
let files = systemlist('git ls-files -o --exclude-standard 2>/dev/null')
|
|
return map(files, "{'line': v:val, 'path': v:val}")
|
|
endfunction
|
|
|
|
let g:startify_lists = [
|
|
\ { 'type': 'files', 'header': [' MRU'] },
|
|
\ { 'type': 'dir', 'header': [' MRU '. getcwd()] },
|
|
\ { 'type': 'sessions', 'header': [' Sessions'] },
|
|
\ { 'type': 'bookmarks', 'header': [' Bookmarks'] },
|
|
\ { 'type': function('s:gitModified'), 'header': [' git modified']},
|
|
\ { 'type': function('s:gitUntracked'), 'header': [' git untracked']},
|
|
\ { 'type': 'commands', 'header': [' Commands'] },
|
|
\ ]
|
|
|
|
" ### quick-scope
|
|
" Trigger a highlight in the appropriate direction only when pressing these keys:
|
|
let g:qs_highlight_on_keys = ['f', 'F', 't', 'T']
|
|
|
|
" wrap words with ``
|
|
" https://stackoverflow.com/questions/24555192/command-for-putting-backticks-around-the-current-word
|
|
nnoremap <F8> ciw``<C-r>"``<Esc>
|
|
xnoremap <F8> c``<C-r>"``<Esc>
|
|
|
|
" ### Keybindings
|
|
" deaktiviere Ex-Mode keybinding
|
|
nnoremap Q <Nop>
|
|
|
|
" Ctrl+S zum speichern
|
|
nnoremap <C-s> :w<CR>
|
|
|
|
" Navigate tabs
|
|
nnoremap <C-j> :bnext<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
|
|
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
|
|
nnoremap <Leader>mm Vap:EasyAlign *\|<cr><esc>
|
|
nnoremap <F7> Vap:EasyAlign *\|<cr><esc>
|
|
"
|
|
" lasse Y wie C oder D funktionieren
|
|
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
|
|
nnoremap <F2> :call ToggleNERDTreeFind()<CR>
|
|
|
|
" toddle Undotree
|
|
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
|
|
|
|
" ### Abbreviations
|
|
iabbrev ncicht nicht
|
|
iabbrev nciht nicht
|
|
|
|
" linenumbers
|
|
nnoremap <Leader>z :set nonumber! norelativenumber!<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
|
|
" trailing whitespaces werden automatisch beim speichern entfernt
|
|
function! Whitespaces_trailing()
|
|
" Remove trailing whitespace
|
|
%s/\s\+$//e
|
|
endfunction
|
|
function! Whitespaces_consecutive()
|
|
" Replace consecutive spaces between words with a single space (only for .md files)
|
|
if &filetype == "markdown"
|
|
%s/\(\w\)\s\+\(\w\)/\1 \2/g
|
|
endif
|
|
endfunction
|
|
function! Whitespaces_lines()
|
|
" Run silent command to remove multiple consecutive empty lines (only for .md files)
|
|
if &filetype == "markdown"
|
|
silent %!cat -s
|
|
endif
|
|
endfunction
|
|
function! Whitespaces_all()
|
|
call Whitespaces_trailing()
|
|
call Whitespaces_consecutive()
|
|
call Whitespaces_lines()
|
|
endfunction
|
|
" Map F9 to execute the custom function
|
|
nnoremap <F9> :call Whitespaces_all()<CR>
|
|
" entferne trailing whitespaces beim speichern
|
|
autocmd BufWritePre * :call Whitespaces_trailing()
|
|
|
|
" 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
|
|
" NERDTree - show hidden files
|
|
let NERDTreeShowHidden=1
|
|
|
|
" NERDTREE - Find file or close
|
|
" https://stackoverflow.com/questions/14964020/is-it-possible-to-configure-behaviour-of-nerdtreetoggle-to-use-nerdtreefind-When
|
|
function! ToggleNERDTreeFind()
|
|
if g:NERDTree.IsOpen()
|
|
execute ':NERDTreeClose'
|
|
else
|
|
execute ':NERDTreeFind'
|
|
endif
|
|
endfunction
|