" Plugins ###################################################################### " Auto completion " needs vim >= 8.1.1719 to support features like popup and text property. if (has('patch-8.1.1719') || has('nvim')) packadd! coc.nvim source $XDG_CONFIG_HOME/vim/coc.nvim.vim endif " Automatically close parentheses, brackets, quotes, etc. packadd! delimitMate " Fuzzy finder packadd! fzf packadd! fzf.vim " Theme packadd! onedark.vim " Git information packadd! vim-gitgutter " Surround text with parentheses, brackets, quotes, tags, etc. let g:surround_no_mappings = 1 packadd! vim-surround source $XDG_CONFIG_HOME/vim/vim-surround.vim " Settings ##################################################################### " hybrid linenumbers set number relativenumber " no timeout when exiting insert-mode " (see https://www.johnhawthorn.com/2012/09/vi-escape-delays/) set timeoutlen=1000 ttimeoutlen=0 " smart case insensitive search (insens: /copy /Copy\c; sens: /Copy /copy\C) set ignorecase smartcase " Tab size set tabstop=4 " Shift the same amount as tabstop set shiftwidth=0 " Highlight current line set cursorline " Auto-wrap text and comments; automatically add comment leader when creating " new lines and delete it when joining; do not break already too long lines; " allow formatting with gq. set formatoptions=tcroqlj " Autoindent new lines set autoindent " Copy structure of the existing lines indent when autoindenting a new line set copyindent " Keep lines under 80 characters. set textwidth=80 " Do not insert two spaces before a new sentence when formatting set nojoinspaces " see :help persistent-undo set undofile " Update every 300ms for better experience with plugins like gitgutter and coc set updatetime=300 " Check for spelling in comments and strings set spell spelllang=en " Show the effect of a command while typing (substitute) if (has('nvim')) set inccommand=nosplit endif " Put new window below/right of current set splitbelow splitright " What is ce there for? cw should include whitespace like dw. if (has('nvim')) set cpoptions-=_ else nmap cw dwi nmap cW dWi endif " Show ruler at 80 and 100 columns set colorcolumn=80,100 " Show menu for possible matches when using command-line completing. if (has('wildmenu')) set wildmenu endif " Command-line completion tab behavior: " First: Complete longest common string and show wildmenu " Second: Complete each full match (Cycle through the menu) set wildmode=longest:full,full " Show typed (partial) command on screen. if (has('cmdline_info')) set showcmd endif " Keybindings ################################################################## " Set leader key let mapleader = "\" " Stop highlighting search result when pressing Return nnoremap :nohlsearch " Indentation jump " https://vim.fandom.com/wiki/Move_to_next/previous_line_with_same_indentation noremap :call search('^'. matchstr(getline('.'), '\(^\s*\)') .'\%<' . line('.') . 'l\S', 'be') noremap :call search('^'. matchstr(getline('.'), '\(^\s*\)') .'\%>' . line('.') . 'l\S', 'e') " Split view navigation " Create new panes nnoremap N :vsplit nnoremap n :split " Move between panes nnoremap nnoremap nnoremap nnoremap " Substitute command if (exists('+inccommand') && &inccommand != '') nnoremap S :%s/ vnoremap S :s/ else " This does not work with live previewing commands (inccommand) since the " replace pattern is already defined and thus everything matching the search " pattern is just deleted. nnoremap S :%s//gc vnoremap S :s//gc endif " Interact with the system clipboard if (has('clipboard') || has('nvim')) noremap y "+y noremap d "+d noremap p "+p noremap P "+P endif " Ctrl-Backspace should delete words in insert mode and on command-line. noremap! " Correct word with best/first suggestion. noremap c 1z= " Umlaute and sz map! ae ä map! Ae Ä map! oe ö map! Oe Ö map! ue ü map! Ue Ü map! sz ß " Jump through jump table but center noremap zz noremap zz nmap " Aesthetics ################################################################### " Use 24-bit (true-color) mode if (has('termguicolors')) set termguicolors " https://github.com/vim/vim/issues/993 if (&term != 'xterm-256color') " set Vim-specific sequences for RGB colors let &t_8f = "\e[38;2;%lu;%lu;%lum" let &t_8b = "\e[48;2;%lu;%lu;%lum" endif endif " use onedark as theme for syntax highlighting syntax on colorscheme onedark " get transparent background of the terminal back " (at least in nvim, i can't get it to work in vanilla) if (has('nvim')) highlight Normal guibg=NONE highlight NonText guibg=NONE endif " Autocommands ################################################################# " Highlight trailing whitespaces " (https://vim.fandom.com/wiki/Highlight_unwanted_spaces) " Create highlight group highlight ExtraWhitespace ctermbg=red guibg=red " Associate with patter (trailing whitespaces) match ExtraWhitespace /\s\+$/ " apply not only to the first window autocmd BufWinEnter * match ExtraWhitespace /\s\+$/ " Do not match when typing at the end of a line autocmd InsertEnter * match ExtraWhitespace /\s\+\%#\@