set title set history=700 set background=dark filetype plugin on filetype indent on syntax enable let mapleader = " " let maplocalleader = " " set autoread " automatically re-read modified files set wildmenu " handy auto-complete menu " Ignore compiled files set wildignore=*.o,*~,*.pyc set ruler " always show current position set cmdheight=2 " height of the command bar set hid " buffer becomes hidden when it abandoned set backspace=eol,start,indent " make backspace not be stupid set whichwrap+=<,>,h,l set list set listchars=trail:·,precedes:«,extends:»,eol:↲,tab:→\ set ignorecase " ignore case when searching set smartcase " be "smart" about case when searching set hlsearch " highlight search results set incsearch " enable incremental search set lazyredraw " don't redraw while executing macros set magic " enable magic for regexps set showmatch " show matching bracket pairs set matchtime=1 set noswapfile set modeline set spell " spell checking, woo set foldcolumn=1 set ruler " always show current position " set tabstop=4 " who the heck uses 8-space tabs? " set shiftwidth=4 " set smarttab set shiftwidth=2 " auto-install vim-plug if empty(glob('~/.vim/autoload/plug.vim')) silent !curl -fLo ~/.vim/autoload/plug.vim --create-dirs \ https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim autocmd VimEnter * PlugInstall --sync | quit endif " begin vim-plug items call plug#begin('~/.vim/bundle') " color schemes Plug 'dylanaraps/wal.vim' " syntax Plug 'cakebaker/scss-syntax.vim' Plug 'calviken/vim-gdscript3' Plug 'leafgarland/typescript-vim' Plug 'lepture/vim-jinja' Plug 'posva/vim-vue' Plug 'nikvdp/ejs-syntax' Plug 'chrisbra/Colorizer' Plug 'noahfrederick/vim-noctu' " functionality Plug 'tpope/vim-sensible' Plug 'tpope/vim-abolish' Plug 'tpope/vim-surround' Plug 'tpope/vim-dispatch' Plug 'tpope/vim-vinegar' Plug 'tpope/vim-sleuth' Plug 'tpope/vim-commentary', "{{{ nmap c Commentary xmap c Commentary omap c Commentary nmap cc CommentaryLine autocmd FileType vue setlocal commentstring=//\ %s "}}} Plug 'tpope/vim-fugitive', "{{{ map \b :Gblame map \l :Glog map \gs :Gstatus "}}} Plug 'justinmk/vim-dirvish', "{{{ nmap \e (dirvish_up) augroup dirvish_mapping autocmd! autocmd! FileType dirvish call DirvishMapping() augroup END function! DirvishMapping() nmap \e gq> endfunction "}}} Plug 'kristijanhusak/vim-dirvish-git' Plug 'mattn/webapi-vim' Plug 'mattn/vim-gist' Plug 'airblade/vim-gitgutter' Plug 'easymotion/vim-easymotion', "{{{ map (easymotion-prefix) "}}} Plug 'habamax/vim-godot' Plug 'neoclide/coc.nvim', {'branch': 'release'}, "{{{ " let g:coc_global_extensions = [ " \ 'coc-css', " \ 'coc-emoji', " \ 'coc-eslint', " \ 'coc-json', " \ 'coc-prettier', " \ 'coc-rls', " \ 'coc-tslint', " \ 'coc-tslint-plugin', " \ 'coc-tsserver', " \ 'coc-yaml', " \ ] Plug 'pappasam/coc-jedi', {'do': 'yarn install --frozen-lockfile'} set signcolumn=yes set updatetime=750 set shortmess+=c inoremap \ pumvisible() ? "\" : \ check_back_space() ? "\" : \ coc#refresh() inoremap pumvisible() ? "\" : "\" function! s:check_back_space() abort let col = col('.') - 1 return !col || getline('.')[col - 1] =~# '\s' endfunction " Remap keys for gotos nmap gd (coc-definition) nmap gy (coc-type-definition) nmap gi (coc-implementation) nmap gr (coc-references) nmap ]p :CocPrev nmap [p :CocNext nmap f (coc-fix-current) " Use to trigger completion. inoremap coc#refresh() " Highlight symbol under cursor on CursorHold autocmd CursorHold * silent call CocActionAsync('highlight') " Use K to show documentation in preview window nnoremap K :call show_documentation() function! s:show_documentation() if (index(['vim','help'], &filetype) >= 0) execute 'h '.expand('') else call CocAction('doHover') endif endfunction " Use to confirm completion, `u` means break undo chain at current position. " Coc only does snippet and additional edit on confirm. inoremap pumvisible() ? "\" : "\u\" " Customize coc appearance hi CocHighlightText cterm=italic "}}} Plug 'vim-airline/vim-airline-themes' Plug 'vim-airline/vim-airline', "{{{ let g:airline_symbols = {} let g:airline_symbols.branch = '⭠' let g:airline_symbols.readonly = '⭤' let g:airline_symbols.linenr = '⭡' let g:airline#extensions#tabline#enabled = 1 let g:airline_theme = 'wal' "}}} Plug 'junegunn/fzf', {'dir': '~/.fzf', 'do': './install --all'} Plug 'junegunn/fzf.vim', "{{{ function! s:buflist() redir => ls silent ls redir END return split(ls,'\n') endfunction function! s:bufopen(e) execute 'buffer' matchstr(a:e, '^[ 0-9]*') endfunction nnoremap :call fzf#run({ \ 'source': reverse(buflist()), \ 'sink': function('bufopen'), \ 'options': '+m', \ 'down': len(buflist()) + 2 \}) function! s:FuzzyFiles() let gitparent=system('git rev-parse --show-toplevel')[:-2] let rootdir='.' if empty(matchstr(gitparent, '^fatal:.*')) silent call fzf#run({ \ 'dir': gitparent, \ 'source': '(git ls-tree -r --name-only HEAD | rg --files)', \ 'sink': 'e', \}) else silent call fzf#run({ \ 'dir': '.', \ 'source': 'rg --files', \ 'sink': 'e', \}) endif endfunction command! -bang -nargs=* Rg \ call fzf#vim#grep( \ 'rg --column --line-number --no-heading --color=always '.shellescape(), 1, \ 0 ? fzf#vim#with_preview('up:60%') \ : fzf#vim#with_preview('right:50%:hidden', '?'), \ 0) nnoremap ; :call FuzzyFiles() nnoremap / :Rg "}}} call plug#end() "--- Visuals highlight ExtraWhitespace ctermbg=20 ctermfg=1 match ExtraWhitespace /\s\+$/ autocmd BufWinEnter * match ExtraWhitespace /\s\+$/ autocmd InsertEnter * match ExtraWhitespace /\s\+\%#\@ :bnext " next buffer map :bprev " prev buffer nmap j " focus window down nmap k " focus window up nmap h " focus window left nmap l " focus window right vnoremap :sort " visual select and sort noremap mzgg=G`z " auto-format entire document nnoremap pu :PlugUpdate " update plugins managed by vim-plugged nnoremap pi :PlugInstall " install new plugins nnoremap pc :PlugClean " clean removed plugins nnoremap zn ]s " next misspelling nnoremap zp [s " prev misspelling nnoremap zf 1z= " replace misspelling with first suggestion nnoremap n :set number! " toggle numbering nnoremap ve :e $MYVIMRC " quick open (literally) this file nmap w :w! " fast save " clear trailing white space nnoremap :let _s=@/ :%s/\s\+$//e :let @/=_s :nohl :unlet _s " prefer ripgrep if available if executable('rg') set grepprg="rg --vimgrep" endif " save with sudo command! W execute 'w !sudo tee %> /dev/null' edit! " read .vimlocal if available if filereadable(expand('~/.vimlocal')) source ~/.vimlocal endif " netrw " nnoremap \e VinegarUp let g:netrw_banner = 0 let g:netrw_liststyle = 3 let g:netrw_altv = 1 let g:netrw_winsize = 25 let g:netrw_browse_split = 4 augroup netrw_mapping autocmd! autocmd FileType netrw call NetrwMapping() autocmd FileType netrw setl bufhidden=wipe augroup END function! NetrwMapping() noremap \e :bd endfunction