dotfiles/.vimrc

176 lines
5.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'
" languagepack
Plugin 'sheerun/vim-polyglot'
" fuzzy finder
Plugin 'ctrlpvim/ctrlp.vim'
" Shellcheck Integration
Plugin 'itspriddle/vim-shellcheck'
" git integration G:
Plugin 'tpope/vim-fugitive'
" statusline
Plugin 'itchyny/lightline.vim'
" buffer in tabline
Plugin 'ap/vim-buftabline'
" start screen
Plugin 'mhinz/vim-startify'
" bracketed paste/ keine set-paste mehr
Plugin 'ConradIrwin/vim-bracketed-paste'
" multi cursor; setze cursor mit \\\
Plugin 'mg979/vim-visual-multi'
" Markdown-Preview in Browser
" :source %
" :PluginInstall
" :call mkdp#util#install()
" Befehle nach Installation notwendig
Plugin 'iamcco/markdown-preview.nvim'
call vundle#end()
" ### allgemeine Optionen
" ### Suche
" While typing a search command, show immediately where the so far typed pattern matches.
set incsearch
" global bei suche immer mit an
set gdefault
" 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
" ### Nummern
" Show line numbers.
set number
" toggle linenumbers
nmap <leader>z :set nonu!<CR>
" ### 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
set showbreak=+++
" https://vim.fandom.com/wiki/Automatic_word_wrapping
set wrap linebreak
" Enable syntax highlighting
syntax on
" Enable mouse drag on window splits
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
" strg+f sucht fuzzy nach dateien
nmap <C-f> :CtrlP<CR>
" strg+l sucht fuzzy in zeilen des aktuellen buffers
nmap <C-l> :CtrlPLine<CR>
" 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)$'
" stelle standard keybinding um
let g:ctrlp_map = ''
let g:ctrlp_extensions = ['line', 'undo']
" ### shellcheck
" farbe für zeilenmarkierung im quickfix-windows
hi QuickFixLine ctermbg=black guibg=black
" mit , + n/p wechsele den Eintrag vor/zurück
nnoremap <leader>n :cn<CR>
nnoremap <leader>p :cp<CR>
" ### 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'
\ },
\ }
" https://shapeshed.com/vim-statuslines/
function! GitBranch()
return system("git rev-parse --abbrev-ref HEAD 2>/dev/null | tr -d '\n'")
endfunction
" ### markdown-preview
nmap <C-m> <Plug>MarkdownPreviewToggle
" 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'] },
\ ]
" ### Keybindings
" deaktiviere Ex-Mode keybinding
:nnoremap Q <Nop>
" Ctrl+w zum speichern
nmap <C-w> :q<CR>
" Ctrl+S zum speichern
nmap <C-s> :w<CR>
" ctrl+P: set paste
nmap <leader>p :set paste!<CR>
" leader-key
:let mapleader = "-"
" 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<C-R>=escape(@",'/\')<CR><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>l :nohlsearch<cr>:diffupdate<cr>:syntax sync fromstart<cr><c-l>