diff options
Diffstat (limited to 'vim/vimrc')
| -rw-r--r-- | vim/vimrc | 189 |
1 files changed, 189 insertions, 0 deletions
diff --git a/vim/vimrc b/vim/vimrc new file mode 100644 index 0000000..a0bbb3d --- /dev/null +++ b/vim/vimrc @@ -0,0 +1,189 @@ +runtime ftplugin/man.vim + +if has("patch-9.0.1799") + packadd! editorconfig +endif + +set nocompatible " don't be compatible to vi +set showcmd " show entered commands in status line +set showmatch " show matching brackets +set autoindent " indent new lines correctly +set hlsearch " highlight search results +set ignorecase " case-insensitive searching +set background=dark " color scheme for dark background +set title " set terminal title +set ruler " show line/column of cursor in status line +set tabstop=4 " display a tab as 4 spaces +set softtabstop=-1 " use value of shiftwidth for softtabstop +set shiftwidth=4 " (auto)indent with 4 spaces (> <) +set noexpandtab " don't expand tabs to spaces +set nobackup " don't keep backup files +set showtabline=2 " always show tab line +set hidden " change buffers without saving +set cursorline " highlight current cursor line +set scrolloff=4 " keep 4 lines context when scrolling +set laststatus=2 " always show status line +set ttimeoutlen=50 " faster switch from insert to normal mode +set noshowmode " don't show current mode (done by airline) +set encoding=utf-8 " use utf8 by default +set number " enable line numbers +set relativenumber " show relative line numbers +set updatetime=100 " update gutter more often +set tags^=./.git/tags; " upwards search for tags file in .git/ +set wildmenu " enable wildmenu for command completion +set wildmode=list:longest,full " use a bash-like command completion mode +set backspace=indent,eol,start " enable backspacing +set diffopt^=indent-heuristic,algorithm:histogram " better diffing +let g:grepcmd="rg --with-filename --column --no-heading --word-regexp --smart-case --line-number --color never" +let &grepprg=g:grepcmd . ' --' " use ripgrep for grepping +let mapleader="," " more convenient leader +syntax on " enable syntax highlighting +filetype plugin indent on + +if exists('*popup_create') + set completeopt=menu,popup " use popup instead of preview window for completions +endif + +set directory=~/.vim/swap,.,~/tmp,/var/tmp,/tmp " directory where to save/search swap files +set viminfo+=n~/.vim/viminfo " different location for viminfo file + +" make indentation and trailing whitespaces visible +set list listchars=tab:·\ ,trail:· + +" autocommands +autocmd FileType yaml setlocal shiftwidth=2 expandtab +autocmd FileType mail setlocal spell spelllang=de_20,en_us +autocmd FileType vimwiki setlocal expandtab + +autocmd InsertEnter * if &number | set norelativenumber | endif +autocmd InsertLeave * if &number | set relativenumber | endif + +" show cursorline only in active window +augroup CursorLine + autocmd! + autocmd VimEnter,WinEnter,BufWinEnter * set cursorline + autocmd WinLeave * set nocursorline +augroup END + +" highlighting settings +if (&t_Co == 88) + highlight CursorLine cterm=NONE ctermbg=81 +elseif (&t_Co == 256) + highlight CursorLine cterm=NONE ctermbg=237 + highlight CursorLineNr cterm=NONE ctermbg=NONE + highlight Folded cterm=NONE ctermbg=239 + highlight SignColumn ctermbg=234 + highlight LineNr ctermfg=lightyellow ctermbg=234 + highlight SpecialKey ctermfg=darkgray + highlight Pmenu ctermbg=darkgray +else + highlight CursorLine cterm=NONE ctermbg=darkgray +endif + +" colorscheme +colorscheme srcery + + +" file browser +let g:netrw_liststyle=3 " tree style listing +let g:netrw_banner=0 " suppress banner on top +"let g:netrw_browse_split=3 " open files in new tab +let g:netrw_list_hide='^\..*$' " don't show hidden files + + +" key mappings +nnoremap <silent> <SPACE> :nohlsearch<CR> +nmap tn :tabnew<CR> +nmap tc :tabclose<CR> +noremap <silent> <F3> :ToggleBufExplorer<CR> +nnoremap <silent> <F4> :TagbarToggle<CR> +nnoremap <silent> <C-p> :Files<CR> + +" disable arrow keys +noremap <Up> <Nop> +noremap <Down> <Nop> +noremap <Left> <Nop> +noremap <Right> <Nop> + +" different keycodes in urxvt +nmap <ESC>[5^ <C-PageUp> +nmap <ESC>[6^ <C-PageDown> + +" more convenient grepping +command -nargs=+ Grep execute 'silent grep! <args>' | execute 'redraw!' | execute 'copen' +"nnoremap <leader>g :Grep <cword><CR> +nnoremap <leader>g :call fzf#vim#grep(g:grepcmd . ' --color always -- ' . expand('<cword>'), 1, fzf#vim#with_preview(), 0)<CR> + + +" folding settings; disabled for now because of performance problems +"set foldmethod=syntax " fold automatically by syntax rules +"set foldlevel=0 " fold from top level +"set foldnestmax=1 " fold only 1 level +"let perl_fold=1 +"let perl_nofold_packages=0 + +" disable unneeded standard plugins +let g:loaded_2html_plugin = 1 +let g:loaded_getscriptPlugin = 1 +let g:loaded_logipat = 1 +let g:loaded_rrhelper = 1 +let g:loaded_vimballPlugin = 1 + +" GPG settings +augroup GnuPGExtra + autocmd User GnuPG setl foldmethod=marker foldclose=all foldopen=insert foldtext=v:folddashes.getline(v:foldstart) +augroup END + +" BufExplorer settings +let g:bufExplorerSplitHorzSize=15 +let g:bufExplorerSplitVertSize=40 +let g:bufExplorerDefaultHelp=0 +let g:bufExplorerShowNoName=1 +let g:bufExplorerFindActive=0 + +" airline settings +let g:airline#extensions#whitespace#enabled=0 +let g:airline#extensions#tabline#enabled=1 + +" LSP settings +packadd lsp +if exists("g:loaded_lsp") + nmap <silent> K :LspHover<CR> + call LspOptionsSet(#{ + \ autoHighlight: v:true, + \ showDiagOnStatusLine: v:true, + \ showDiagWithVirtualText: v:true, + \ usePopupInCodeAction: v:true, + \ }) + + if executable("clangd") + call LspAddServer([#{ + \ name: 'clangd', + \ filetype: ['c', 'cpp'], + \ path: 'clangd', + \ args: ['--background-index'] + \ }]) + endif + + if executable("rust-analyzer") + call LspAddServer([#{ + \ name: 'rust-analyzer', + \ filetype: ['rust'], + \ path: 'rust-analyzer', + \ args: [], + \ syncInit: v:true, + \ initializationOptions: #{ + \ inlayHints: #{ + \ typeHints: #{ + \ enable: v:true + \ }, + \ parameterHints: #{ + \ enable: v:true + \ } + \ }, + \ } + \ }]) + endif +endif + +" vim: set et:sw=4:sts=4 |
