"================== " Plugin Management "================== if has('nvim') let s:vim_plug_file="~/.local/share/nvim/site/autoload/plug.vim" let s:vim_plug_dir="~/.local/share/nvim/plugged" let s:local_init_file="~/.config/nvim/local_init.vim" let s:local_plugins_file="~/.config/nvim/local_plugins.vim" else let s:vim_plug_file="~/.vim/autoload/plug.vim" let s:vim_plug_dir="~/.vim/plugged" let s:local_init_file="~/.vim/local_init.vim" let s:local_plugins_file="~/.vim/local_plugins.vim" endif " Download vim-plug if it's not already present. " Remove these lines to disable automatic downloading of vim-plug if !filereadable(expand(s:vim_plug_file)) echom system("curl -fLo " . s:vim_plug_file . " --create-dirs " \ . "https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim") endif " Specify a directory for plugins call plug#begin(s:vim_plug_dir) " To see the description/code for the plugin loaded by the line " " Plug 'user/repo' " " go to https://github.com/user/repo. Plug 'vim-scripts/a.vim' Plug 'tyok/ack.vim' Plug 'ctrlpvim/ctrlp.vim' Plug 'vim-scripts/drawit' Plug 'gregsexton/gitv' Plug 'valloric/ListToggle' Plug 'lifepillar/vim-solarized8' Plug 'scrooloose/nerdcommenter' Plug 'scrooloose/nerdtree' Plug 'tyok/nerdtree-ack' Plug 'mklabs/split-term.vim' Plug 'tpope/tpope-vim-abolish' Plug 'SirVer/ultisnips' Plug 'vim-airline/vim-airline' Plug 'vim-airline/vim-airline-themes' Plug 'moll/vim-bbye' Plug 'ntpeters/vim-better-whitespace' Plug 'rhysd/vim-clang-format' Plug 'tpope/vim-fugitive' Plug 'weynhamz/vim-plugin-minibufexpl' Plug 'tpope/vim-sleuth' Plug 'wesQ3/vim-windowswap' Plug 'valloric/YouCompleteMe' " If you add additional "Plug 'user/repo'" lines in the file specified by " s:local_plugins_file, those plugins will be loaded as well. if filereadable(expand(s:local_plugins_file)) exec "source " . s:local_plugins_file endif " Initialize plugin system call plug#end() "============================================ " Set leader. This is used for many mappings. "============================================ let mapleader=";" "========================================= " Settings/Mappings for particular plugins "========================================= "----------- " Solarized8 "----------- " This sets Solarized8 to use true Solarized colors in gVim and Neovim while " falling back to the 256 color approximation in terminal Vim. if (has("termguicolors")) set termguicolors else set t_Co=256 " Uncomment the following line if you've set up your terminal to use " Solarized colors. "let g:solarized_use16=1 endif silent! colorscheme solarized8_flat "-------------- " YouCompleteMe "-------------- " Jump to definition. nnoremap gg :YcmCompleter GoTo let g:ycm_always_populate_location_list=1 " Apply fix-it suggestion. nnoremap fi :YcmCompleter FixIt "------ " a.vim "------ " Toggle between header/source (Using a.vim) nnoremap a :A "----------- " ListToggle "----------- " Toggle the location list on and off. Useful for checking YouCompleteMe " results. let g:lt_location_list_toggle_map = 'lo' " Toggle the quickfix list on and off. let g:lt_quickfix_list_toggle_map = 'lq' "---------- " ctrlp.vim "---------- let g:ctrlp_working_path_mode = 'rw' let g:ctrlp_custom_ignore = '\v[\/](build|doc)$' " Launch CtrlP. Use this and then start typing fragments of the file path. nnoremap ff :CtrlP "------------ " vim-airline "------------ set laststatus=2 set showtabline=2 "------------------- " vim-airline-themes "------------------- let g:airline_theme='sol' "----- " gitv "----- " Launch Gitv nnoremap gv :Gitv "--------- " nerdtree "--------- " Launch NerdTree (file system viewer). nnoremap nt :NERDTree " Launch NerdTree with the current file selected. nnoremap nf :NERDTreeFind "------------- " vim-fugitive "------------- " Show the diff to HEAD for the current file. nnoremap gd :Gdiff " Show the git status of the repo. nnoremap gs :Gstatus " Fold method set foldmethod=syntax "----------------- " vim-clang-format "----------------- let g:clang_format#detect_style_file=1 " Call clang-format on the current file. autocmd FileType c,cpp,objc nnoremap cf :ClangFormat " Call clang-format on the selected portion of the current file. autocmd FileType c,cpp,objc vnoremap cf :ClangFormat "------------------------ " vim-windowswap Settings "------------------------ let g:windowswap_map_keys = 0 "prevent default bindings " Swap the contents of two windows. Press ss while in the first " window, then navigate to the second window and press ss again. nnoremap ss :call WindowSwap#EasyWindowSwap() "=================================================================== " Other settings/mappings that are useful when working with Drake "=================================================================== "---------------------------- " Highlight the 80-th column. "---------------------------- autocmd FileType c,cpp set cc=80 "------------------------------------------- " Ignore CamelCase words when spell checking "------------------------------------------- fun! IgnoreCamelCaseSpell() syn match CamelCase /\<[A-Z][a-z]\+[A-Z].\{-}\>/ contains=@NoSpell transparent syn cluster Spell add=CamelCase endfun autocmd BufRead,BufNewFile * :call IgnoreCamelCaseSpell() "---------------------------------------- " Recognize doxygen comments as comments. "---------------------------------------- autocmd Filetype c,cpp set comments^=:/// "--------------- " Misc. Settings "--------------- " Use filetype plugins. filetype plugin on " Do not highlight all search matches. set nohlsearch " Show line numbers set number "============================================================= " Other settings/mappings that may be useful in general. YYMV. "============================================================= "--------------------- " Buffer configuration "--------------------- set hidden " Open next buffer in the current window. nmap ff :bnext " Open previous buffer in the current window. nmap FF :bprevious "----------------------- " 'Ergonomics' mappings. "----------------------- " Make getting from INSERT to NORMAL less of a stretch. imap jj " Use + navigation keys to jump between windows in both NORMAL and " INSERT modes. nnoremap J j nnoremap K k nnoremap H h nnoremap L l inoremap J j inoremap K k inoremap H h inoremap L l " Save the current file. nnoremap ww :w " Close the current file. nnoremap qq :q " Save and close the current file. nnoremap wq :w:q " Close all files. nnoremap qa :qa " Use as a replacement for ":". nnoremap : "---------------------------------- " Terminal management (Neovim only) "---------------------------------- if has('nvim') " Open a new terminal in a horizontal split. nnoremap tj :Termxji " Open a new terminal in a vertical split. nnoremap tl :VTerm " Go from TERMINAL mode to NORMAL mode. tnoremap tq " Go to the next tab while in TERMINAL mode. tnoremap gt gt " Move to an adjacent window while in TERMINAL mode. tnoremap J j tnoremap K k tnoremap H h tnoremap L l let g:disable_key_mappings=1 set splitright autocmd TermOpen * setlocal nonumber endif "---------------------- " Edit/source this file "---------------------- let s:current_file=expand(':p') if !exists("*EditVimrc") function EditVimrc() execute 'split' s:current_file endfunction endif if !exists("*SourceVimrc") function SourceVimrc() execute 'source' s:current_file endfunction endif " Edit this file. nnoremap ev :call EditVimrc() " Source this file. nnoremap sv :call SourceVimrc() " If you put more mappings or other magic in the file specified by " s:local_init_file, those will be added here. if filereadable(expand(s:local_init_file)) exec "source " . s:local_init_file endif