set nocompatible " No VI compatibility set autoread " Detect file changes outside vim function! BuildComposer(info) if a:info.status != 'unchanged' || a:info.force if has('nvim') !cargo build --release else !cargo build --release --no-default-features --features json-rpc endif endif endfunction " call plug#begin('~/.local/share/nvim/plugged') " call plug#begin('~/.vim/plugged') Plug 'tomtom/tcomment_vim' Plug 'chriskempson/base16-vim' Plug 'itchyny/lightline.vim' Plug 'sheerun/vim-polyglot' Plug 'editorconfig/editorconfig-vim' Plug 'godlygeek/tabular' Plug 'tpope/vim-fugitive' Plug 'tpope/vim-surround' Plug 'jiangmiao/auto-pairs' Plug 'mattn/emmet-vim', { 'for': 'html' } " Zen coding at it's best" Plug 'othree/html5.vim', { 'for': 'html' } Plug 'skwp/greplace.vim' Plug 'junegunn/fzf', { 'dir': '~/.fzf', 'do': './install --all' } Plug 'junegunn/fzf.vim' Plug 'ternjs/tern_for_vim', { 'for': 'js' } Plug 'Shougo/deoplete.nvim' Plug 'mhartington/nvim-typescript' Plug 'w0rp/ale' Plug 'euclio/vim-markdown-composer', { 'do': function('BuildComposer') } Plug 'SirVer/ultisnips' Plug 'honza/vim-snippets' Plug 'tpope/vim-unimpaired' " All of your Plugins must be added before the following line call plug#end() " absolute width of netrw window let g:netrw_winsize = -28 " tree-view let g:netrw_liststyle = 3 " sort is affecting only: directories on the top, files below let g:netrw_sort_sequence = '[\/]$,*' " Leader C is the prefix for code related mappîngs noremap cc :Tcomment set background=dark " """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" " Lightline " let g:lightline = { 'colorscheme': 'base16-default-dark', } "vim-lightline set laststatus=2 "vim-lightline set noshowmode "vim-lightline "Tabularize vnoremap cee :Tabularize /= "tabular vnoremap cet :Tabularize /# "tabular vnoremap ce :Tabularize / " " make backspaces delete sensibly set backspace=indent,eol,start set autowrite set listchars=tab:>.,trail:.,extends:#,nbsp:. set smartcase set ignorecase set backupdir=~/.vim/tmp/ " for the backup files set directory=~/.vim/tmp/ " for the swap files inoremap jj set hidden " Some kind of buffer tweak set history=1000 set undolevels=1000 set title " Set title of the window set clipboard=unnamed " Use OS clipboard set encoding=utf-8 set mouse=a set lazyredraw set ttyfast set showmatch " Highlight matching pair set nobackup " Disable swapfiles set nowritebackup set noswapfile set listchars=eol:¬ set visualbell " No noise just flash set hlsearch set incsearch set magic set showmatch "Remove visual delay set timeoutlen=1000 ttimeoutlen=0 set wildmenu set ruler set ai "Auto indent set si "Smart indent set noerrorbells set novisualbell set t_vb= set tm=500 syntax enable set ffs=unix,dos,mac "To check set expandtab set smarttab set shiftwidth=2 set tabstop=2 set lbr set tw=500 set ai "Auto indent set si "Smart indent set pastetoggle=sp set shiftwidth=2 set softtabstop=2 " Visual tweaks " ============= set number " Display number on the sidebar set relativenumber set colorcolumn=80 set nowrap set linebreak set diffopt+=vertical " Open new split panes to right and bottom, which feels more natural set splitbelow set splitright vnoremap * :call VisualSelection('f', '') vnoremap # :call VisualSelection('b', '') vnoremap > >gv vnoremap < <gv " Map to / (search) and Ctrl- to ? (backwards search) map / map ? " Disable highlight when is pressed map :noh " Smart way to move between windows map j map k map h map l " Close the current buffer map bd :Bclose " Close all the buffers map ba :1,1000 bd! " Useful mappings for managing tabs map tn :tabnew map to :tabonly map tc :tabclose map tm :tabmove map t :tabnext " Let 'tl' toggle between this and the last accessed tab let g:lasttab = 1 nmap tl :exe "tabn ".g:lasttab au TabLeave * let g:lasttab = tabpagenr() " Opens a new tab with the current buffer's path " Super useful when editing files in the same directory map te :tabedit =expand("%:p:h")/ " Switch CWD to the directory of the open buffer map cd :cd %:p:h:pwd " Return to last edit position when opening files (You want this!) autocmd BufReadPost * \ if line("'\"") > 0 && line("'\"") <= line("$") | \ exe "normal! g`\"" | \ endif " Remember info about open buffers on close set viminfo^=% """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" " => Spell checking """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" " Pressing ,ss will toggle and untoggle spell checking map ss :setlocal spell! " Shortcuts using map sn ]s map sp [s map sa zg map s? z= """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" " => Turn persistent undo on " means that you can undo even when you close a buffer/VIM """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" try set undodir=~/.vim_runtime/temp_dirs/undodir set undofile catch endtry ""PLUGINS map nn :Explore map nf :Vexplore nnoremap cd :cd %:p:h let base16colorspace=256 colorscheme base16-default-dark " Shortcuts map ff :Ag " map ff :grep map ch :lclose map oh :lopen nnoremap gs :Gstatus nnoremap gc :Gcommit -v -q nnoremap ga :Gcommit --amend nnoremap gt :Gcommit -v -q % nnoremap gd :Gdiff nnoremap ge :Gedit nnoremap gr :Gread nnoremap gw :Gwrite nnoremap gl :silent! Glog nnoremap gp :Ggrep nnoremap gm :Gmove nnoremap gb :Git branch nnoremap go :Git checkout nnoremap gps :Dispatch! git push nnoremap gpl :Dispatch! git pull "keep indend on paste ":nnoremap p p`[v`]=`]` nnoremap np p nnoremap p p=`] nnoremap :GundoToggle nmap > :vertical resize +10 nmap < :vertical resize -10 set grepprg=ag nmap :FZF nmap :GitFiles nmap (fzf-maps-n) xmap (fzf-maps-x) omap (fzf-maps-o) " Insert mode completion imap (fzf-complete-word) " imap (fzf-complete-path) imap (fzf-complete-file-ag) imap (fzf-complete-line) " Advanced customization using autoload functions inoremap fzf#vim#complete#word({'left': '15%'}) nnoremap p :Buffers nnoremap Sp :History imap fzf#vim#complete#path('git ls-files $(git rev-parse --show-toplevel)') function s:formatJSON() execute "%!python -m json.tool" set syntax=json endfunction command FormatJSON call s:formatJSON() autocmd FileType typescript setlocal completeopt+=menu,preview "Cursor if exists('$TMUX') let &t_SI = "\Ptmux;\\]50;CursorShape=1\x7\\\" let &t_EI = "\Ptmux;\\]50;CursorShape=0\x7\\\" else let &t_SI = "\]50;CursorShape=1\x7" let &t_EI = "\]50;CursorShape=0\x7" endif let $NVIM_TUI_ENABLE_TRUE_COLOR=1 let $NVIM_TUI_ENABLE_CURSOR_SHAPE=1 """"""""""""""""" " Tern settings """"""""""""""""" let g:tern_show_argument_hints='on_hold' " and let g:tern_map_keys=1 " Useful mappings for managing tabs map tn :tabnew map to :tabonly map tc :tabclose map tm :tabmove map t :tabnext " Shortcuts using map sn ]s map sp [s map sa zg map s? z= :nnoremap h :nnoremap j :nnoremap k :nnoremap l " use tab to forward cycle inoremap pumvisible() ? "\" : "\" " use tab to backward cycle inoremap pumvisible() ? "\" : "\" " Enable deoplete at startup let g:deoplete#enable_at_startup = 1 let g:ale_linters = { \ 'typescript': ['tslint', 'tsserver'], \ 'html': [] \} let g:ale_fixers = { \ 'javascript': ['eslint', 'remove_trailing_lines'], \ 'typescript': ['remove_trailing_lines'] \} " Set this setting in vimrc if you want to fix files automatically on save. " This is off by default. let g:ale_fix_on_save = 1 set tabstop=2 set shiftwidth=2 set expandtab set shiftwidth=2 set softtabstop=2 " Smaller undo inoremap . .u inoremap ? ?u inoremap ! !u inoremap , ,u " Fzf preview window ? command! -bang -nargs=* Ag \ call fzf#vim#ag(, \ 0 ? fzf#vim#with_preview('up:60%') \ : fzf#vim#with_preview('right:50%:hidden', '?'), \ 0) " Trigger configuration. Do not use if you use https://github.com/Valloric/YouCompleteMe. let g:UltiSnipsExpandTrigger = "s" let g:UltiSnipsJumpForwardTrigger = "sn" let g:UltiSnipsJumpBackwardTrigger="sb" set synmaxcol=128 syntax sync minlines=256