" vim: set et sw=2 ts=2 tw=80 : " SETTINGS if !has('nvim') setlocal cm=blowfish2 end " activate mouse support set mouse=a " allow unsaved hidden buffers set hidden " set relative line numbers set number relativenumber " set highlighting and continous search set hlsearch incsearch " show n-column limiter when textwidth is set set colorcolumn=+1 if has('nvim') " prevent terminal buffers to be closed when changing buffer autocmd TermOpen * set bufhidden=hide " restore line numbers for all buffers (revert changes of cmd below) autocmd BufCreate * set rnu nu " remove line numbers to terminal autocmd TermOpen * set nornu nonu end " set autoindent on` set autoindent " Make :find work on all files in :pwd set path+=** set wildignore+=**/node_modules/**,*~ " set netrw preferred style to tree let g:netrw_liststyle = 3 " remove netrw top banner let g:netrw_banner = 0 let g:netrw_list_hide = netrw_gitignore#Hide() " ADDITIONAL COMMANDS " emulate system clipboard inoremap "+pa vnoremap "+y inoremap " make escape work in terminal and send ESC to terminal with C-Esc tnoremap tnoremap " activate autocompletion using `key` when under a 'keyword' char " (a-zA-Z + relevant characters for current language), otherwise just send TAB function! AutocompleteIfKeyword() let curcol = col('.') - 1 " column position before the cursor if !curcol " if at the beginning of the line return "\" " insert TAB character elseif getline('.')[curcol - 1] =~ '\k' " if current character is a 'keyword' return g:autocomplete_key " activate autocompletion for current word else " if the current char is not a 'keyword' return "\" " insert TAB characher end endfunction " autocomplete using `key` with tab if cursor is under a 'keyword' char. " for = see: https://stackoverflow.com/questions/10862457 inoremap =AutocompleteIfKeyword() " use standard vim autocomplete as fallback let g:autocomplete_key = "\" " autocomplete with Tsuquyomi on TypeScript files autocmd FileType typescript let g:autocomplete_key = "\\" " Automatically save folds for each file augroup AutoSaveFolds autocmd! autocmd BufWinLeave * mkview autocmd BufWinEnter * silent! loadview augroup END " clear search pattern with F2 noremap :let @/ = "" " Use "," as leader let mapleader = "," " Git grep with Leader g nnoremap g :Grepper -tool git " Switch between Windows with: Leader w nnoremap w " show next buffer with: leader n nnoremap n :bn " show previous buffer with: leader n nnoremap p :bp " Fix indentation with: Leader i nnoremap i mzgg=G`z " Delete buffer with: Leader d nnoremap d :bp\|bd # " move to next tab with: Leader t nnoremap t :tabnext tnoremap :tabnext nnoremap I WildignoreFromGitignore " clear trailing spaces in file function! g:ClearTrailingSpaces() silent! %s/\s\s*$//g let @/ = "" " clear last search endfunction " remove trailing spaces with: Leader t s nnoremap s :call ClearTrailingSpaces() " automatically remove trailing spaces when saving a file autocmd BufWrite * call ClearTrailingSpaces() " Reload config with: Leader R nnoremap R :source ~/.config/nvim/init.vim " show Vim's true competitor with: Leader r c m nnoremap rcm :!open https://youtu.be/jn40Ugz0vuk " open netrw in directory of current file nnoremap e :Ex " close quickfix window with: Leader Q nnoremap Q :ccl " Insert in the end of file with Leader c nnoremap c GA " Go files: launch go lint quickfix with: Leader q autocmd FileType go nnoremap q :w:GoLint " TypeScript files: launch TypeScript lint quickfix with: Leader q autocmd FileType typescript nnoremap q :TsuQuickFix " COLORSCHEME " set colorscheme to onedark.im for nvim and airline packadd! onedark.vim colorscheme onedark let g:airline_theme='onedark' " PACKAGES " vim-fish setup syntax enable filetype plugin indent on " Set up :make to use fish for syntax checking. autocmd FileType fish compiler fish if has("vms") set nobackup " do not keep a backup file, use versions instead else set backup " keep a backup file (restore to previous version) if has('persistent_undo') set undofile " keep an undo file (undo changes after closing) endif endif