From eb4fbe62bb1f24a1bae63792b234d1265c205091 Mon Sep 17 00:00:00 2001 From: Marvin Borner Date: Tue, 17 Mar 2020 23:00:37 +0100 Subject: Wht did I spend my whole day on a awesome vim config? :) --- .config/nvim/init.vim | 149 +++++++++++++++++++++++++++++++++++++++++++------- 1 file changed, 130 insertions(+), 19 deletions(-) (limited to '.config/nvim/init.vim') diff --git a/.config/nvim/init.vim b/.config/nvim/init.vim index 3f7103a..0a996f3 100644 --- a/.config/nvim/init.vim +++ b/.config/nvim/init.vim @@ -12,7 +12,19 @@ endif call plug#begin('~/.config/nvim/plugged') " Features +Plug '907th/vim-auto-save' +" Plug 'ycm-core/YouCompleteMe' +Plug 'SirVer/ultisnips' +Plug 'honza/vim-snippets' +Plug 'junegunn/fzf.vim' +Plug 'airblade/vim-gitgutter' +Plug 'haya14busa/incsearch.vim' +Plug 'qpkorr/vim-bufkill' +Plug 'tpope/vim-unimpaired' +Plug 'tpope/vim-commentary' Plug 'tpope/vim-surround' +Plug 'tpope/vim-repeat' +Plug 'w0rp/ale' " Menus Plug 'scrooloose/nerdtree' @@ -26,49 +38,148 @@ Plug 'flazz/vim-colorschemes' call plug#end() " Basics +nnoremap c "_c +filetype plugin indent on +syntax on set bg=dark set go=a -set nohlsearch +set ff=unix +set mouse=a set nocompatible -nnoremap c "_c -filetype plugin on -syntax on +set autoindent +set autoread +set autowrite +set backspace=indent,eol,start +set cindent +set cinkeys-=0# +set cino= +set copyindent +set expandtab +set fileformats=unix,dos,mac +set formatoptions=tcqn1 +set hidden +set history=200 +set hlsearch +set ignorecase +set incsearch +set infercase +set laststatus=2 +set linebreak +set list +set listchars=tab:»\ ,extends:›,precedes:‹,nbsp:·,trail:· +set matchtime=2 +set nomodeline +set nobackup +set nonumber +set visualbell t_vb= +set nowritebackup +set ruler +set scroll=4 +set sessionoptions-=options +set shiftround +set shiftwidth=4 +set shortmess+=A +set showbreak= +set showmatch +set sidescrolloff=3 +set smartcase +set softtabstop=4 +set suffixes+=.pyc +set tabstop=4 +set textwidth=100 +set wildmenu +set wildmode=list:longest,full +set wildignore=*.class,*.o,*~,*.pyc,.git,node_modules set encoding=utf-8 set number relativenumber " Basic keymaps -map w :w -map q :q -map l gt -map h gT - -" Autocomplete -set wildmode=longest,list,full +nmap j gj +nmap k gk +nmap w :w +nmap q :q +nmap b :BD +nmap l :bn +" TODO: Fix the following line +nmap h :bp +nmap S :nohlsearch + +" Several non-retard options +nnoremap ' ` +autocmd VimResized * :wincmd = + +" Autosave +let g:auto_save=1 +let g:auto_save_silent=1 " Splitting set splitbelow splitright -map h -map j -map k -map l +nmap h +nmap j +nmap k +nmap l + +" FZF +nmap ; :Buffers +nmap t :Files +nmap c :Colors +nmap s :Rg! +let $FZF_DEFAULT_COMMAND = 'rg --files --follow -g "!{.git,node_modules}/*" 2>/dev/null' +command! -bang -nargs=* Rg + \ call fzf#vim#grep( + \ 'rg --column --line-number --no-heading --color=always --smart-case -g "!{*.lock,*-lock.json}" '.shellescape(), 1, + \ 0 ? fzf#vim#with_preview('up:40%') + \ : fzf#vim#with_preview('right:50%:hidden', '?'), + \ 0) + +" Git implementation +let g:gitgutter_sign_added = '▌' +let g:gitgutter_sign_modified = '▌' +let g:gitgutter_sign_removed = '▌' +let g:gitgutter_sign_modified_removed = '∙' +nmap ]g :GitGutterNextHunk +nmap [g :GitGutterPrevHunk +augroup VimDiff + autocmd! + autocmd VimEnter,FilterWritePre * if &diff | GitGutterDisable | endif +augroup END + +" Better search highlighting TODO: Fix neovim specific double caret +nmap / (incsearch-forward) +nmap ? (incsearch-backward) +nmap g/ (incsearch-stay) + +" ALE +let g:ale_sign_warning = '▲' +let g:ale_sign_error = '✗' +highlight link ALEWarningSign String +highlight link ALEErrorSign Title +nmap F :ALEFix +nmap ]w :ALENextWrap +nmap [w :ALEPreviousWrap +nmap f (ale_fix) +augroup VimDiff + autocmd! + autocmd VimEnter,FilterWritePre * if &diff | ALEDisable | endif +augroup END " File explorer nnoremap n :NERDTreeToggle nnoremap f :NERDTreeFind -autocmd bufenter * if (winnr("$") == 1 && exists("b:NERDTree") && b:NERDTree.isTabTree()) | q | endif +" autocmd bufenter * if (winnr("$") == 1 && exists("b:NERDTree") && b:NERDTree.isTabTree()) | q | endif autocmd StdinReadPre * let s:std_in=1 autocmd VimEnter * if argc() == 0 && !exists("s:std_in") | NERDTree | endif autocmd VimEnter * if argc() == 1 && isdirectory(argv()[0]) && !exists("s:std_in") | exe 'NERDTree' argv()[0] | wincmd p | ene | exe 'cd '.argv()[0] | endif let g:NERDTreeDirArrowExpandable = '' let g:NERDTreeDirArrowCollapsible = '' let NERDTreeMinimalUI=1 +let g:NERDTreeMarkBookmarks=0 +let g:NERDTreeAutoDeleteBuffer=1 +let g:NERDTreeStatusLine=-1 " Root master super save cnoremap w!! execute 'silent! write !sudo tee % >/dev/null' edit! -" Remove whitespace on save -autocmd BufWritePre * %s/\s\+$//e - " Airline config let g:airline_theme='minimalist' let g:airline#extensions#tabline#enabled=1 -- cgit v1.2.3