call plug#begin('~/.config/nvim/plugged') " colorschemes Plug 'chriskempson/base16-vim' " utilities Plug 'ctrlpvim/ctrlp.vim' Plug 'scrooloose/nerdtree', { 'on': ['NERDTreeToggle', 'NERDTreeFind'] } | Plug 'Xuyuanp/nerdtree-git-plugin' | Plug 'ryanoasis/vim-devicons' Plug 'mileszs/ack.vim' Plug 'Raimondi/delimitMate' Plug 'tpope/vim-commentary' Plug 'tpope/vim-unimpaired' Plug 'tpope/vim-endwise' Plug 'tpope/vim-ragtag' Plug 'tpope/vim-surround' Plug 'benmills/vimux' Plug 'bling/vim-airline' " Plug 'scrooloose/syntastic' Plug 'benekastah/neomake' Plug 'tpope/vim-fugitive' Plug 'tpope/vim-repeat' Plug 'garbas/vim-snipmate' Plug 'editorconfig/editorconfig-vim' Plug 'MarcWeber/vim-addon-mw-utils' Plug 'tomtom/tlib_vim' Plug 'sotte/presenting.vim' Plug 'ervandew/supertab' Plug 'tpope/vim-dispatch' " Plug 'mtth/scratch.vim' Plug 'tpope/vim-vinegar' " Plug 'tpope/vim-abolish' Plug 'AndrewRadev/splitjoin.vim' Plug 'vim-scripts/matchit.zip' Plug 'tpope/vim-sleuth' " detect indent style (tabs vs. spaces) Plug 'sickill/vim-pasta' " context-aware pasting Plug 'junegunn/goyo.vim', { 'on': 'Goyo' } " distraction-free writing Plug 'junegunn/limelight.vim', { 'on': 'Limelight' } " focus tool. Good for presentating with vim " language-specific plugins Plug 'mattn/emmet-vim', { 'for': 'html' } Plug 'gregsexton/MatchTag', { 'for': 'html' } Plug 'othree/html5.vim', { 'for': 'html' } Plug 'pangloss/vim-javascript', { 'for': 'javascript' } Plug 'moll/vim-node', { 'for': 'javascript' } Plug 'jelera/vim-javascript-syntax', { 'for': 'javascript' } Plug 'mxw/vim-jsx', { 'for': 'jsx' } Plug 'elzr/vim-json', { 'for': 'json' } " Plug 'Quramy/tsuquyomi', { 'for': 'typescript', 'do': 'npm install' } Plug 'Shougo/vimproc.vim', { 'do': 'make' } Plug 'leafgarland/typescript-vim', { 'for': 'typescript' } " Plug 'juvenn/mustache.vim', { 'for': 'mustache' } Plug 'mustache/vim-mustache-handlebars' Plug 'digitaltoad/vim-jade', { 'for': 'jade' } Plug 'cakebaker/scss-syntax.vim', { 'for': 'scss' } Plug 'wavded/vim-stylus', { 'for': ['stylus', 'markdown'] } Plug 'groenewege/vim-less', { 'for': 'less' } Plug 'ap/vim-css-color', { 'for': 'css' } Plug 'hail2u/vim-css3-syntax', { 'for': 'css' } Plug 'itspriddle/vim-marked', { 'for': 'markdown', 'on': 'MarkedOpen' } Plug 'tpope/vim-markdown', { 'for': 'markdown' } Plug 'fatih/vim-go', { 'for': 'go' } Plug 'timcharper/textile.vim', { 'for': 'textile' } " Plug 'tclem/vim-arduino' " Plug 'davidoc/taskpaper.vim' call plug#end() """"""""""""""""""""""""""""""""""""""""""""""""""""""""""" " => General """"""""""""""""""""""""""""""""""""""""""""""""""""""""""" " load plugins from vundle " source ~/.vim/plugins.vim " Abbreviations abbr funciton function abbr teh the abbr tempalte template abbr fitler filter set nocompatible " not compatible with vi set autoread " detect when a file is changed " make backspace behave in a sane manner set backspace=indent,eol,start " set a map leader for more key combos let mapleader = ',' let g:mapleader = ',' set history=1000 " change history to 1000 set textwidth=120 " Tab control set noexpandtab " insert tabs rather than spaces for set smarttab " tab respects 'tabstop', 'shiftwidth', and 'softtabstop' set tabstop=4 " the visible width of tabs set softtabstop=4 " edit as if the tabs are 4 characters wide set shiftwidth=4 " number of spaces to use for indent and unindent set shiftround " round indent to a multiple of 'shiftwidth' set completeopt+=longest if has('mouse') set mouse=a " set ttymouse=xterm2 endif set clipboard=unnamed " faster redrawing set ttyfast set diffopt+=vertical " highlight conflicts match ErrorMsg '^\(<\|=\|>\)\{7\}\([^=].\+\)\?$' " file type specific settings if has('autocmd') && !exists('autocommands_loaded') let autocommands_loaded = 1 autocmd FileType yaml setlocal ts=2 sts=2 sw=2 expandtab autocmd FileType make setlocal ts=8 sts=8 sw=8 noexpandtab autocmd FileType ruby setlocal ts=2 sts=2 sw=2 expandtab autocmd FileType html setlocal ts=4 sts=4 sw=4 noexpandtab indentkeys-=* autocmd FileType jade setlocal ts=2 sts=2 sw=2 noexpandtab autocmd FileType *.md.js :call SyntasticReset autocmd FileType markdown,textile setlocal textwidth=0 wrapmargin=0 wrap spell autocmd FileType .xml exe ":silent %!xmllint --format --recover - 2>/dev/null" autocmd FileType crontab setlocal nobackup nowritebackup "autocmd WinEnter * setlocal cursorline "autocmd WinLeave * setlocal nocursorline " automatically resize panes on resize autocmd VimResized * exe 'normal! \=' autocmd BufWritePost .vimrc source % autocmd BufWritePost .vimrc.local source % " save all files on focus lost, ignoring warnings about untitled buffers autocmd FocusLost * silent! wa autocmd BufNewFile,BufRead *.ejs set filetype=html autocmd BufNewFile,BufRead *.ino set filetype=c autocmd BufNewFile,BufRead *.svg set filetype=xml " make quickfix windows take all the lower section of the screen when there " are multiple windows open autocmd FileType qf wincmd J autocmd BufNewFile,BufReadPost *.md set filetype=markdown let g:markdown_fenced_languages = ['css', 'javascript', 'js=javascript', 'json=javascript', 'stylus', 'html'] " autocmd! BufEnter * call ApplyLocalSettings(expand(':p:h')) autocmd! BufWritePost * Neomake endif " code folding settings set foldmethod=syntax " fold based on indent set foldnestmax=10 " deepest fold is 10 levels set nofoldenable " don't fold by default set foldlevel=1 """"""""""""""""""""""""""""""""""""""""""""""""""""""""""" " => User Interface """"""""""""""""""""""""""""""""""""""""""""""""""""""""""" set so=7 " set 7 lines to the cursors - when moving vertical set wildmenu " enhanced command line completion set hidden " current buffer can be put into background set showcmd " show incomplete commands set noshowmode " don't show which mode disabled for PowerLine set wildmode=list:longest " complete files like a shell set scrolloff=3 " lines of text around cursor set shell=$SHELL set cmdheight=1 " command bar height set title " set terminal title " Searching set ignorecase " case insensitive searching set smartcase " case-sensitive if expresson contains a capital letter set hlsearch set incsearch " set incremental search, like modern browsers set nolazyredraw " don't redraw while executing macros set magic " Set magic on, for regex set showmatch " show matching braces set mat=2 " how many tenths of a second to blink " error bells set noerrorbells set visualbell set t_vb= set tm=500 " switch syntax highlighting on syntax on set encoding=utf8 let base16colorspace=256 " Access colors present in 256 colorspace" set t_Co=256 " Explicitly tell vim that the terminal supports 256 colors" execute "set background=".$BACKGROUND execute "colorscheme ".$THEME " set number " show line numbers " set relativenumber " show relative line numbers set number " show the current line number" set wrap "turn on line wrapping set wrapmargin=8 " wrap lines when coming within n characters from side set linebreak " set soft wrapping set showbreak=… " show ellipsis at breaking set autoindent " automatically set indent of new line set smartindent """"""""""""""""""""""""""""""""""""""""""""""""""""""""""" " => Files, backups, and undo """"""""""""""""""""""""""""""""""""""""""""""""""""""""""" "set nobackup "set nowritebackup "set noswapfile set backupdir=~/.vim-tmp,~/.tmp,~/tmp,/var/tmp,/tmp set directory=~/.vim-tmp,~/.tmp,~/tmp,/var/tmp,/tmp """"""""""""""""""""""""""""""""""""""""""""""""""""""""""" " => StatusLine """"""""""""""""""""""""""""""""""""""""""""""""""""""""""" set laststatus=2 " show the satus line all the time """"""""""""""""""""""""""""""""""""""""""""""""""""""""""" " => Mappings """"""""""""""""""""""""""""""""""""""""""""""""""""""""""" " General mappings/shortcuts for functionality " Additional, plugin-specific mappings are located under " the plugins section " Close the current buffer " noremap :q " remap esc inoremap jk " markdown to html nmap md :%!markdown --html4tags " remove extra whitespace nmap :%s/\s\+$ " wipout buffer nmap b :bw " shortcut to save nmap , :w " disable Ex mode noremap Q " set paste toggle set pastetoggle= " toggle paste mode map v :set paste! " edit ~/.config/nvim/init.vim map ev :e! ~/.config/nvim/init.vim " edit gitconfig map eg :e! ~/.gitconfig " clear highlighted search noremap :set hlsearch! hlsearch? " activate spell-checking alternatives nmap ;s :set invspell spelllang=en " toggle invisible characters set invlist set listchars=tab:▸\ ,eol:¬,trail:⋅,extends:❯,precedes:❮ highlight SpecialKey ctermbg=none " make the highlighting of tabs less annoying set showbreak=↪ nmap l :set list! " Textmate style indentation vmap [ ] >gv nmap [ << nmap ] >> " switch between current and last buffer nmap . " enable . command in visual mode vnoremap . :normal . map :call WinMove('h') map :call WinMove('j') map :call WinMove('k') map :call WinMove('l') map wc :wincmd q " toggle cursor line nnoremap i :set cursorline! " scroll the viewport faster nnoremap 3 nnoremap 3 " moving up and down work as you would expect nnoremap j gj nnoremap k gk nnoremap ^ g^ nnoremap $ g$ " search for word under the cursor nnoremap / "fyiw :/f " inoremap =Smart_TabComplete() map r :call RunCustomCommand() " map s :call SetCustomCommand() let g:silent_custom_command = 0 " helpers for dealing with other people's code nmap \t :set ts=4 sts=4 sw=4 noet nmap \s :set ts=4 sts=4 sw=4 et nmap w :setf textile :Goyo """"""""""""""""""""""""""""""""""""""""""""""""""""""""""" " => Functions """"""""""""""""""""""""""""""""""""""""""""""""""""""""""" " Window movement shortcuts " move to the window in the direction shown, or create a new window function! WinMove(key) let t:curwin = winnr() exec "wincmd ".a:key if (t:curwin == winnr()) if (match(a:key,'[jk]')) wincmd v else wincmd s endif exec "wincmd ".a:key endif endfunction " recursively search up from dirname, sourcing all .vimrc.local files along the way function! ApplyLocalSettings(dirname) " convert windows paths to unix style let l:curDir = substitute(a:dirname, '\\', '/', 'g') " walk to the top of the dir tree let l:parentDir = strpart(l:curDir, 0, strridx(l:curDir, '/')) if isdirectory(l:parentDir) call ApplyLocalSettings(l:parentDir) endif " now walk back down the path and source .vimsettings as you find them. " child directories can inherit from their parents let l:settingsFile = a:dirname . '/.vimrc.local' if filereadable(l:settingsFile) exec ':source' . l:settingsFile endif endfunction " smart tab completion function! Smart_TabComplete() let line = getline('.') " current line let substr = strpart(line, -1, col('.')+1) " from the start of the current " line to one character right " of the cursor let substr = matchstr(substr, '[^ \t]*$') " word till cursor if (strlen(substr)==0) " nothing to match on empty string return '\' endif let has_period = match(substr, '\.') != -1 " position of period, if any let has_slash = match(substr, '\/') != -1 " position of slash, if any if (!has_period && !has_slash) return '\\' " existing text matching elseif ( has_slash ) return '\\' " file matching else return '\\' " plugin matching endif endfunction " execute a custom command function! RunCustomCommand() up if g:silent_custom_command execute 'silent !' . s:customcommand else execute '!' . s:customcommand endif endfunction function! SetCustomCommand() let s:customcommand = input('Enter Custom Command$ ') endfunction function! TrimWhiteSpace() %s/\s\+$//e endfunction function! HiInterestingWord(n) " Save our location. normal! mz " Yank the current word into the z register. normal! "zyiw " Calculate an arbitrary match ID. Hopefully nothing else is using it. let mid = 86750 + a:n " Clear existing matches, but don't worry if they don't exist. silent! call matchdelete(mid) " Construct a literal pattern that has to match at boundaries. let pat = '\V\<' . escape(@z, '\') . '\>' " Actually match the words. call matchadd("InterestingWord" . a:n, pat, 1, mid) " Move back to our original location. normal! `z endfunction nnoremap 1 :call HiInterestingWord(1) nnoremap 2 :call HiInterestingWord(2) nnoremap 3 :call HiInterestingWord(3) nnoremap 4 :call HiInterestingWord(4) nnoremap 5 :call HiInterestingWord(5) nnoremap 6 :call HiInterestingWord(6) hi def InterestingWord1 guifg=#000000 ctermfg=16 guibg=#ffa724 ctermbg=214 hi def InterestingWord2 guifg=#000000 ctermfg=16 guibg=#aeee00 ctermbg=154 hi def InterestingWord3 guifg=#000000 ctermfg=16 guibg=#8cffba ctermbg=121 hi def InterestingWord4 guifg=#000000 ctermfg=16 guibg=#b88853 ctermbg=137 hi def InterestingWord5 guifg=#000000 ctermfg=16 guibg=#ff9eb8 ctermbg=211 hi def InterestingWord6 guifg=#000000 ctermfg=16 guibg=#ff2c4b ctermbg=195 function! HtmlUnEscape() silent s/<//eg silent s/&/\&/eg endfunction nnoremap u :call HtmlUnEscape() """"""""""""""""""""""""""""""""""""""""""""""""""""""""""" " => Plugins """"""""""""""""""""""""""""""""""""""""""""""""""""""""""" " close NERDTree after a file is opened let g:NERDTreeQuitOnOpen=0 " show hidden files in NERDTree let NERDTreeShowHidden=1 " remove some files by extension let NERDTreeIgnore = ['\.js.map$'] " Toggle NERDTree nmap k :NERDTreeToggle " expand to the path of the file in the current buffer nmap y :NERDTreeFind " map fuzzyfinder (CtrlP) plugin " nmap t :CtrlP nmap r :CtrlPBuffer let g:ctrlp_map='t' let g:ctrlp_dotfiles=1 let g:ctrlp_working_path_mode = 'ra' " Fugitive Shortcuts nmap gs :Gstatus nmap ge :Gedit nmap gr :Gread nmap gb :Gblame nmap m :MarkedOpen! nmap mq :MarkedQuit " toggle Limelight nmap f :Limelight!! let g:neomake_javascript_jshint_maker = { \ 'args': ['--verbose'], \ 'errorformat': '%A%f: line %l\, col %v\, %m \(%t%*\d\)', \ } let g:neomake_javascript_enabled_markers = ['jshint', 'jscs'] " CtrlP ignore patterns " let g:ctrlp_custom_ignore = { " \ 'dir': '\.git$\|node_modules$\|bower_components$\|\.hg$\|\.svn$', " \ 'file': '\.exe$\|\.so$' " \ } " only show files that are not ignored by git let g:ctrlp_user_command = ['.git/', 'git --git-dir=%s/.git ls-files -oc --exclude-standard'] " search the nearest ancestor that contains .git, .hg, .svn let g:ctrlp_working_path_mode = 2 " airline options let g:airline_powerline_fonts=1 let g:airline_left_sep='' let g:airline_right_sep='' let g:airline_theme='base16' " don't hide quotes in json files let g:vim_json_syntax_conceal = 0 let g:SuperTabCrMapping = 0 if (has("gui_running")) set guioptions=egmrt set background=light colorscheme solarized let g:airline_left_sep='' let g:airline_right_sep='' let g:airline_powerline_fonts=0 let g:airline_theme='solarized' endif call ApplyLocalSettings(expand('.'))