From 92d7a08690e044f833b3651c293a85eb2b0796ab Mon Sep 17 00:00:00 2001 From: ViViDboarder Date: Thu, 26 Mar 2015 10:09:26 -0700 Subject: [PATCH] More dark vim! --- .gitignore | 5 + vim-sync-append.sh | 104 +------- vim/autoload/.gitkeep | 0 vim/backup/.gitkeep | 0 vim/rc/edit.rc.vim | 15 ++ vim/rc/init.rc.vim | 23 ++ vim/rc/keymap.rc.vim | 71 ++++++ vim/rc/plugins.rc.vim | 225 +++++++++++++++++ vim/rc/plugins/ctrlp.rc.vim | 0 vim/rc/ui.rc.vim | 73 ++++++ vim/tmp/.gitkeep | 0 vimrc | 480 +++--------------------------------- 12 files changed, 465 insertions(+), 531 deletions(-) create mode 100644 .gitignore create mode 100644 vim/autoload/.gitkeep create mode 100644 vim/backup/.gitkeep create mode 100644 vim/rc/edit.rc.vim create mode 100644 vim/rc/init.rc.vim create mode 100644 vim/rc/keymap.rc.vim create mode 100644 vim/rc/plugins.rc.vim create mode 100644 vim/rc/plugins/ctrlp.rc.vim create mode 100644 vim/rc/ui.rc.vim create mode 100644 vim/tmp/.gitkeep diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..05b82ad --- /dev/null +++ b/.gitignore @@ -0,0 +1,5 @@ +vim/autoload/plug.vim +vim/plugged/* +vim/rc/*.local.rc.vim +vim/tmp/*.swp +vim/.netrwhist diff --git a/vim-sync-append.sh b/vim-sync-append.sh index 2ce39ab..3707ee9 100755 --- a/vim-sync-append.sh +++ b/vim-sync-append.sh @@ -4,6 +4,11 @@ ############################ #! /bin/bash +if [ -d ~/.vim ] || [ -f ~/.vimrc ]; then + echo "Vim files already exist. Please backup or remove .vim and .vimrc" + exit 1 +fi + # Try to load .bashrc to load rvm functions if [ -f ~/.bashrc ]; then . ~/.bashrc @@ -14,104 +19,19 @@ VIM_SYNC_DIR=$(dirname $0) cd $VIM_SYNC_DIR VIM_SYNC_DIR=$(pwd) -# Verify git is installed (although needed to checkout -command -v git >/dev/null 2>&1 || { - echo "Error: git required for install"; - exit 1; -} -# Clone vundle if not done already -if [ ! -d ~/.vim/bundle/vundle ]; then - echo "Installing vundle" - mkdir -p ~/.vim/bundle - git clone https://github.com/gmarik/vundle.git ~/.vim/bundle/vundle -fi +ln -s $VIM_SYNC_DIR/vimrc ~/.vimrc +ln -s $VIM_SYNC_DIR/vim ~/.vim -# Make backup and tmp dirs -echo "Building temp and backup dirs" -mkdir -p ~/.vim/backup -mkdir -p ~/.vim/tmp -mkdir -p ~/.vim/doc - -# If a .vimrc_sync doesn't exist, link it -if [[ ! ( -f ~/.vimrc_sync ) ]]; then - echo "Linking sync'd vimrc" - ln -s $VIM_SYNC_DIR/vimrc ~/.vimrc_sync -fi - -# If a .vim_drpobox dir doesn't exist, link it -if [[ ! ( -d ~/.vim_sync ) ]]; then - echo "Linking sync'd vim runtime" - ln -s $VIM_SYNC_DIR/vim ~/.vim_sync -fi - -# if there is no .vimrc file already, make a blank one -if [[ ( ! -f ~/.vimrc ) ]]; then - echo "No ~/.vimrc found, creating one" - touch ~/.vimrc -fi - -# if not already sourcing the synced version, source it -if ! ( grep -q 'source ~/.vimrc_sync' ~/.vimrc ); then - echo "Source sync'd vimrc in vimrc" - echo '' >> ~/.vimrc - echo '"import vimrc from synced' >> ~/.vimrc - echo 'source ~/.vimrc_sync' >> ~/.vimrc -fi - -if ! ( grep -q 'set runtimepath+=$HOME/.vim_sync' ~/.vimrc ); then - echo "Add sync'd vim dir to runtime" - echo '' >> ~/.vimrc - echo '"add vim directory from synced' >> ~/.vimrc - echo 'set runtimepath+=$HOME/.vim_sync' >> ~/.vimrc -fi +# # Download and install vim-plug +# curl -fLo ~/.vim/autoload/plug.vim https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim # Install all bundles echo "Install all bundles" -vim +BundleInstall! +qall +vim +PlugInstall +qall -echo "Compile vimproc" -cd ~/.vim/bundle/vimproc.vim && make -cd - - -# Compile CommandT if possible -# See if ruby is installed -if command -v ruby >/dev/null 2>&1; then - # Make sure GCC is installed - if command -v gcc >/dev/null 2>&1; then - # Use system ruby - command -v rvm >/dev/null 2>&1 && { rvm use system; } - echo "Compile Command T's C extension" - cd ~/.vim/bundle/Command-T/ruby/command-t - ruby extconf.rb - make - fi -fi - -# Display warning methods related to Command T -vim --version | grep -q '\+ruby' || { echo "Warning: Default vim does not include ruby as needed for Command T"; } -command -v ruby >/dev/null 2>&1 || { echo "Warning: ruby required for Command T"; } -command -v gcc >/dev/null 2>&1 || { echo "Warning: gcc required for Command T"; } - -# Execute vim's update of the helptags -VIM_RESULT=$(vim +"helptags ~/.vim/doc" +"q") - -if [[ "$VIM_RESULT" == *SEGV* ]]; then - echo "Seg Faulted. Retry with different ruby" - cd ~/.vim/bundle/Command-T/ruby/command-t && /opt/local/bin/ruby* extconf.rb && make && cd - - - # Retry - vim +"helptags ~/.vim/doc" +"q" -fi - -# Warn if ctags does not exist -command -v ctags >/dev/null 2>&1 || { echo "Warning: ctags required for Tag List ---- Debian: apt-get install ctags ---- OSX (MacPorts): port install ctags"; } - -echo "Note: If VIM Segfaults try the following:" -echo " cd ~/.vim/bundle/Command-T/ruby/command-t && /opt/local/bin/ruby* extconf.rb && make && cd -" -echo "" +vim --version | grep -q '\+ruby' || { echo "Warning: Default vim does not include ruby."; } +vim --version | grep -q '\+python' || { echo "Warning: Default vim does not include python"; } echo "All done!" exit 0 diff --git a/vim/autoload/.gitkeep b/vim/autoload/.gitkeep new file mode 100644 index 0000000..e69de29 diff --git a/vim/backup/.gitkeep b/vim/backup/.gitkeep new file mode 100644 index 0000000..e69de29 diff --git a/vim/rc/edit.rc.vim b/vim/rc/edit.rc.vim new file mode 100644 index 0000000..71e3721 --- /dev/null +++ b/vim/rc/edit.rc.vim @@ -0,0 +1,15 @@ +" Tab functionality +set expandtab +set tabstop=4 +set shiftwidth=4 +set softtabstop=4 +set autoindent +" Ensure backspace actually works +set backspace=2 +" +" allow for cursor beyond last character +set virtualedit=onemore +" lines to scroll when cursor leaves screen +set scrolljump=5 +" minimum lines to keep above and below cursor +set scrolloff=3 diff --git a/vim/rc/init.rc.vim b/vim/rc/init.rc.vim new file mode 100644 index 0000000..0f8dde0 --- /dev/null +++ b/vim/rc/init.rc.vim @@ -0,0 +1,23 @@ +"Allows filetype detection +filetype on + +" Set settings values +filetype plugin indent on + +" Allow arrow keys +set nocompatible + +" Use more convenient leader +let mapleader="," + +" Enable mouse input +set mousehide +set mouse=a + +" Set backup dirs +set backup +set backupdir=~/.vim/backup +set directory=~/.vim/tmp + +" Filetype extension +au BufRead,BufNewFile *.md set syntax=markdown diff --git a/vim/rc/keymap.rc.vim b/vim/rc/keymap.rc.vim new file mode 100644 index 0000000..49c63b5 --- /dev/null +++ b/vim/rc/keymap.rc.vim @@ -0,0 +1,71 @@ +" Remap jk to esc +inoremap jk +" Easy esc on TEX Yoda +inoremap `` +vnoremap `` + +" Change Working Directory to that of the current file +cmap cwd lcd %:p:h +cmap cd. lcd %:p:h + +" Bind Make to F5 like other IDEs +nnoremap :Make! + +" Remap Ctrl+Space for auto Complete +inoremap +inoremap + +" Toggle highlighting with \hr (highlight row) +nnoremap hr :set cursorline! + +" Toggle Line numbers with Ctrl+N double tap +nmap :set invnumber +nmap ln :set invnumber + +" Toggle line wrap with Ctrl+L double tap +nmap :set wrap! +nmap lw :set wrap! + +" Toggle White Space +nmap ws :set list! + +" Map Shift+U to redo +nnoremap + +" Stupid shift key fixes +cmap WQ wq +cmap Wq wq +cmap W w +cmap Q q +cmap Q! q! +" Stupid semicolon files +cnoremap w; w +cnoremap W; w +cnoremap q; q +cnoremap Q; q +" Avoid accidental Ex-mode +:map Q + +" Clearing highlighted search +nmap / :set hlsearch! hlsearch? +noremap :set hlsearch! hlsearch? +" Clear search +nmap cs :nohlsearch + +" Code fold +nmap cf va{zf%:nohlsearch + +" Paste over +vnoremap pp p +vnoremap po "_dP + +" Buffer nav +nmap gb :bn +nmap gB :bp + +" Command to display TODO tags in project +command Todo Ag! TODO + +" Easy update tags +command TagsUpdate Dispatch ctags -R . + diff --git a/vim/rc/plugins.rc.vim b/vim/rc/plugins.rc.vim new file mode 100644 index 0000000..57b4363 --- /dev/null +++ b/vim/rc/plugins.rc.vim @@ -0,0 +1,225 @@ +" Navigation {{ +Plug 'file-line' +Plug 'tpope/vim-vinegar' +Plug 'tpope/vim-fugitive', { 'on': ['Gblame', 'Gdiff', 'Gcommit', 'Gstatus', 'Gwrite'] } " {{ + nnoremap gb :Gblame + nnoremap gc :Gcommit + nnoremap gd :Gdiff + nnoremap gs :Gstatus + nnoremap gw :Gwrite + " }} +Plug 'sandeepcr529/Buffet.vim', { 'on': 'Bufferlist' } +" {{ + nnoremap :Bufferlist +" }} +Plug 'ctrlpvim/ctrlp.vim' +" {{ + " Ensure max height isn't too large. (for performance) + let g:ctrlp_max_height = 10 + " Conditional Mappings + let g:ctrlp_map = '' + " Allow ctrl p to open over the initial nerdtree window + let g:ctrlp_dont_split = 'netrw' + " Support tag jumping + let g:ctrlp_extensions = ['tag', 'buffertag'] + " Support Apex language + let g:ctrlp_buftag_types = { + \ 'apex' : '--language-force=c#', + \ 'go' : { + \ 'bin' : 'gotags', + \ 'args' : '-sort -silent', + \} + \} + " Leader Commands + nnoremap b :CtrlPBuffer + nnoremap t :CtrlPBufTag + nnoremap r :CtrlPTag + nnoremap u :CtrlPCurFile + nnoremap m :CtrlPMRUFiles + + " Special stuff for The Silver Searcher + if executable('ag') + " use ag + set grepprg=ag\ --nogroup\ --nocolor + " use ag for CtrlP + let g:ctrlp_user_command = 'ag %s -l --nocolor --nogroup -g ""' + " ag is fast enough we don't need cache + let g:ctrlp_use_caching = 0 + endif + " }} +" }} + +" Search {{ +if executable('ag') + Plug 'rking/ag.vim' + " {{ + nmap a :Ag + nmap i* :Ag-i'\b\b' + nmap * :Ag'\b\b' + " }} +else + Plug 'mileszs/ack.vim' + " {{ + nmap a :Ack + nmap i* :Ack-i'\b\b' + nmap * :Ack'\<\>' + " }} +endif +" }} + +" Autocomplete {{ +if has('lua') + Plug 'Shougo/neocomplete.vim' + " {{ + let g:acp_enableAtStartup = 0 + let g:neocomplete#enable_at_startup = 1 + "let g:neocomplete#enable_smart_case = 1 + let g:neocomlete#max_list=10 + " }} +else + Plug 'Shougo/neocomplcache.vim' + " {{ + let g:neocomplcache_enable_at_startup = 1 + "let g:neocomplcache_enable_smart_case = 1 + let g:neocomplcache_max_list = 10 + "let g:neocomplcache_enable_camel_case_completion = 1 + let g:neocomplcache_enable_fuzzy_completion = 1 + if !exists('g:neocomplcache_force_omni_patterns') + let g:neocomplcache_force_omni_patterns = {} + endif + let g:neocomplcache_force_omni_patterns.python = + \ '\%([^. \t]\.\|^\s*@\|^\s*from\s.\+import \|^\s*from \|^\s*import \)\w*' + " alternative pattern: '\h\w*\|[^. \t]\.\w*' + " }} +end +" {{ + " Enable omni completion. + autocmd FileType css setlocal omnifunc=csscomplete#CompleteCSS + autocmd FileType html,markdown setlocal omnifunc=htmlcomplete#CompleteTags + autocmd FileType javascript setlocal omnifunc=javascriptcomplete#CompleteJS + " Skip python because we have jedi-vim + "autocmd FileType python setlocal omnifunc=pythoncomplete#Complete + autocmd FileType python setlocal omnifunc=jedi#completions + autocmd FileType ruby setlocal omnifunc=rubycomplete#Complete + autocmd FileType xml setlocal omnifunc=xmlcomplete#CompleteTags + +" }} + +" Programming {{ +Plug 'majutsushi/tagbar' " {{ + nnoremap :TagbarToggle + " Autofocus tagbar + let g:tagbar_autofocus = 1 + " }} +Plug 'scrooloose/syntastic' " {{ + let g:syntastic_html_tidy_ignore_errors = [ + \ 'proprietary attribute "ng-show"', + \ 'proprietary attribute "ng-controller"', + \ 'proprietary attribute "ng-repeat"', + \ 'proprietary attribute "ng-app"', + \ 'proprietary attribute "ng-click"' + \ ] + let g:syntastic_python_checkers = ['flake8'] + let g:syntastic_python_flake8_args='--max-line-length=80' + " let g:syntastic_python_checkers = ['pep8'] + " " let g:syntastic_python_pep8_args='--ignore=E501' + " " let g:syntastic_python_checkers = ['jshint'] + " " let g:syntastic_javascript_jshint_args='--ignore=E501' + " +" }} +Plug 'tomtom/tcomment_vim', { 'on': ['TComment', 'TCommentBlock'] } " {{ + nnoremap // :TComment + vnoremap // :TCommentBlock + " }} +Plug 'benekastah/neomake' +" }} + +" GUI {{ +Plug 'bling/vim-airline' " {{ + " Use short-form mode text + let g:airline_mode_map = { + \ '__' : '-', + \ 'n' : 'N', + \ 'i' : 'I', + \ 'R' : 'R', + \ 'c' : 'C', + \ 'v' : 'V', + \ 'V' : 'V', + \ '' : 'V', + \ 's' : 'S', + \ 'S' : 'S', + \ '' : 'S', + \ } + let g:airline#extensions#whitespace#trailing_format = 'tw[%s]' + let g:airline#extensions#whitespace#mixed_indent_format = 'i[%s]' + let g:airline_left_sep='' + let g:airline_left_alt_sep='' + let g:airline_right_sep='' + let g:airline_right_alt_sep='' + let g:airline#extensions#tabline#enabled = 1 + let g:airline#extensions#tabline#left_sep = ' ' + let g:airline#extensions#tabline#left_alt_sep = '|' + " }} +Plug 'gregsexton/MatchTag' +Plug 'rizzatti/dash.vim', { 'on': 'Dash'} +" }} + +" Filetypes {{ +Plug 'PreserveNoEOL' " {{ + let g:PreserveNoEOL = 1 + " }} +Plug 'ViViDboarder/vim-forcedotcom' +Plug 'avakhov/vim-yaml' +Plug 'dart-lang/dart-vim-plugin' +Plug 'fatih/vim-go' +Plug 'groovy.vim' +Plug 'hsanson/vim-android' +Plug 'pangloss/vim-javascript' +Plug 'pdurbin/vim-tsv' +Plug 'tfnico/vim-gradle' +" Python {{ + Plug 'alfredodeza/coveragepy.vim' + Plug 'alfredodeza/pytest.vim' + Plug 'davidhalter/jedi-vim' + " {{ + let g:jedi#completions_enabled = 0 + let g:jedi#auto_vim_configuration = 0 + " }} + Plug 'klen/python-mode' + " {{ + let g:pymode_lint = 1 + let g:pymode_lint_on_write = 0 + let g:pymode_lint_checkers = ['flake8'] + let g:pymode_rope = 0 + let g:pymode_rope_completion = 0 + let g:pymode_rope_complete_on_dot = 0 + let g:pymode_breakpoint = 0 + "}} + " }} +" }} + +" Themes {{ +Plug 'altercation/vim-colors-solarized' +Plug 'candy.vim' +Plug 'eclipse.vim' +Plug 'morhetz/gruvbox' +Plug 'nanotech/jellybeans.vim' +Plug 'nuvola.vim' +Plug 'summerfruit256.vim' +Plug 'therubymug/vim-pyte' +Plug 'vividchalk.vim' +Plug 'wombat256.vim' +" }} + +" System {{ +Plug 'Shougo/vimproc.vim', { 'do': 'make' } +Plug 'tpope/vim-dispatch' +Plug 'tpope/vim-repeat' +" emacs bindinds in insert +Plug 'tpope/vim-rsi' +Plug 'ViViDboarder/QFixToggle' +" {{ + " Toggle QuickFix window + nnoremap :QFix +" }} +" }} diff --git a/vim/rc/plugins/ctrlp.rc.vim b/vim/rc/plugins/ctrlp.rc.vim new file mode 100644 index 0000000..e69de29 diff --git a/vim/rc/ui.rc.vim b/vim/rc/ui.rc.vim new file mode 100644 index 0000000..86344f6 --- /dev/null +++ b/vim/rc/ui.rc.vim @@ -0,0 +1,73 @@ +" Display filename at bottom of window +set ls=2 +"enable line numbers +set nu + +" Highlights the line the cursor is on +set cursorline +:hi CursorLine cterm=NONE ctermbg=darkred guibg=darkred guifg=white + +" Syntax Hightlighting +syntax on + +" Enable search highlighting +set hls + + +" Color Schemes {{ +" Set theme based on $VIM_COLOR variable +try + if !empty($VIM_COLOR) + colorscheme $VIM_COLOR + else + if has("gui_running") + colorscheme wombat256mod + else + colorscheme vividchalk + endif + endif +catch /^Vim\%((\a\+)\)\=:E185/ + " Colorschemes not installed yet + " This happens when first installing bundles + colorscheme default +endtry + +" Set Airline theme +if g:colors_name == 'github' + let g:airline_theme = 'solarized' +endif +" }} + +" Set gui fonts {{ +if has("gui_running") + if has("gui_win32") + set guifont=Consolas:h10:b + elseif has("gui_macvim") + try + set guifont=DejaVu\ Sans\ Mono\ for\ Powerline:h11 + catch + " Failed to set font + endtry + endif +endif +" }} + +" Set xterm and screen/tmux's title {{ +set notitle +set titlestring=vim\ %{expand(\"%t\")} +if &term =~ "^screen" + " pretend this is xterm. it probably is anyway, but if term is left as + " `screen`, vim doesn't understand ctrl-arrow. + if &term == "screen-256color" + set term=xterm-256color + else + set term=xterm + endif + + " gotta set these *last*, since `set term` resets everything + set t_ts=k + set t_fs=\ + set t_ut= +endif +set title +" }} diff --git a/vim/tmp/.gitkeep b/vim/tmp/.gitkeep new file mode 100644 index 0000000..e69de29 diff --git a/vimrc b/vimrc index 32aad85..b9ccf01 100644 --- a/vimrc +++ b/vimrc @@ -1,452 +1,54 @@ -" Install Vundle Packages -filetype off +" A lot of inspiration from Shougo -set rtp+=~/.vim/bundle/vundle/ -call vundle#rc() +" Note: Skip initialization for vim-tiny or vim-small. +if !1 | finish | endif -" let Vundle manage Vundle -" required! -Plugin 'gmarik/vundle' - -" Rest of my bundles - -" -- File Nav -- -"Plugin 'scrooloose/nerdtree' " File tree navigation -Plugin 'tpope/vim-vinegar' " Simple file navigation -Plugin 'a.vim' " Switch to alternate file -Plugin 'file-line' " Allow opening to a line from file name using : -Plugin 'tpope/vim-fugitive' " Git integration -Plugin 'christoomey/vim-tmux-navigator' - -" -- Fuzzy Finders -- -Plugin 'ctrlpvim/ctrlp.vim' " Quick find files in project - -" -- Buffer Nav -- -Plugin 'sandeepcr529/Buffet.vim' " Quick buffer switching - -" -- Nav in file -- -Plugin 'majutsushi/tagbar' " Ctags file parsing -Plugin 'scrooloose/syntastic' " Syntax checking -Plugin 'ViViDboarder/QFixToggle' " Easy Toggle of QuickFix window -if executable('ag') - Plugin 'rking/ag.vim' " Project searching -else - Plugin 'mileszs/ack.vim' " Project Searching +if &compatible + set nocompatible endif -" -- Text Manipulation -- -Plugin 'tomtom/tcomment_vim' " Easy comments -Plugin 'tpope/vim-surround' " Surround for wrapping text +function! s:smart_source_rc(name) + call s:source_rc(a:name . '.rc.vim') + call s:source_rc(a:name . '.local.rc.vim') +endfunction -" -- GUI -- -Plugin 'gregsexton/MatchTag' -Plugin 'bling/vim-airline' " Custom Status Line -"Powerline Config -"If using a patched font: https://github.com/Lokaltog/vim-powerline/wiki/Patched-fonts -"let g:airline_powerline_fonts = 1 +function! s:source_rc(path) + let l:f_path = fnameescape(expand('~/.vim_sync/rc/' . a:path)) + if filereadable(l:f_path) + execute 'source' . l:f_path + endif +endfunction -" -- System -- -Plugin 'tpope/vim-dispatch' " Allow async make -Plugin 'tpope/vim-rsi' " emacs bindinds in insert -Plugin 'tpope/vim-repeat' " Repeat mapped commands with . -" Needs to be compiled -Plugin 'Shougo/vimproc.vim' " Async for plugins +let s:is_windows = has('win16') || has('win32') || has('win64') +let s:is_cygwin = has('win32unix') +let s:is_sudo = $SUDO_USER !=# '' && $USER !=# $SUDO_USER + \ && $HOME !=# expand('~'.$USER) + \ && $HOME ==# expand('~'.$SUDO_USER) -if has('lua') - Plugin 'Shougo/neocomplete.vim' " Autocomplete -else - Plugin 'Shougo/neocomplcache.vim' " Autocomplete -end +function! IsWindows() + return s:is_windows +endfunction -" -- Themes -- -Plugin 'vividchalk.vim' -Plugin 'wombat256.vim' -Plugin 'nanotech/jellybeans.vim' -Plugin 'candy.vim' -Plugin 'therubymug/vim-pyte' -Plugin 'eclipse.vim' -Plugin 'summerfruit256.vim' -Plugin 'nuvola.vim' -Plugin 'altercation/vim-colors-solarized' -Plugin 'morhetz/gruvbox' -"Plugin 'BusyBee.vim' -"Plugin 'github.vim' +function! IsMac() + return !s:is_windows && !s:is_cygwin + \ && (has('mac') || has('macunix') || has('gui_macvim') || + \ (!executable('xdg-open') && + \ system('uname') =~? '^darwin')) +endfunction -" -- Filetypes -- -Plugin 'pdurbin/vim-tsv' -Plugin 'pangloss/vim-javascript' -Plugin 'fatih/vim-go' -Plugin 'PreserveNoEOL' -Plugin 'hsanson/vim-android' -Plugin 'groovy.vim' -Plugin 'tfnico/vim-gradle' -Plugin 'dart-lang/dart-vim-plugin' -Plugin 'avakhov/vim-yaml' -"Plugin 'chrisbra/csv.vim' -" SFDC -Plugin 'ViViDboarder/vim-forcedotcom' -"Plugin 'ViViDboarder/force-vim' -"Plugin 'ViViDboarder/vim-abuse-the-force' -" Python -Plugin 'klen/python-mode' -Plugin 'davidhalter/jedi-vim' -Plugin 'alfredodeza/pytest.vim' -Plugin 'alfredodeza/coveragepy.vim' - -" *************************** -" Built in settings -" *************************** - -"Allows filetype detection -filetype on - -" Set settings values -filetype plugin indent on - -" Allow arrow keys -set nocompatible - -" Use more convenient leader -let mapleader="," - -" Enable mouse input -set mousehide -set mouse=a - -" Tab functionality -set expandtab -set tabstop=4 -set shiftwidth=4 -set softtabstop=4 -set autoindent -" Ensure backspace actually works -set backspace=2 -" -" allow for cursor beyond last character -set virtualedit=onemore -" lines to scroll when cursor leaves screen -set scrolljump=5 -" minimum lines to keep above and below cursor -set scrolloff=3 - -" Display filename at bottom of window -set ls=2 - -" Set backup dirs -set backup -set backupdir=~/.vim/backup -set directory=~/.vim/tmp - -"enable line numbers -set nu - -" Highlights the line the cursor is on -set cursorline -:hi CursorLine cterm=NONE ctermbg=darkred guibg=darkred guifg=white - -" Syntax Hightlighting -syntax on - -" Enable search highlighting -set hls - -" Change Working Directory to that of the current file -cmap cwd lcd %:p:h -cmap cd. lcd %:p:h - -" ******************************** -" GUI SETTINGS -" ***************************** - -" Set theme based on $VIM_COLOR variable -try - if !empty($VIM_COLOR) - colorscheme $VIM_COLOR - else - if has("gui_running") - colorscheme wombat256mod - else - colorscheme vividchalk - endif - endif -catch /^Vim\%((\a\+)\)\=:E185/ - " Colorschemes not installed yet - " This happens when first installing bundles - colorscheme default -endtry - -" Set Airline theme -if g:colors_name == 'github' - let g:airline_theme = 'solarized' +" 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 endif -" Set gui fonts -if has("gui_running") - if has("gui_win32") - set guifont=Consolas:h10:b - elseif has("gui_macvim") - try - set guifont=DejaVu\ Sans\ Mono\ for\ Powerline:h11 - catch - " Failed to set font - endtry - endif -endif +call s:source_rc('init.rc.vim') -" Set xterm title, and inform vim of screen/tmux's syntax for doing the same -set titlestring=vim\ %{expand(\"%t\")} -if &term =~ "^screen" - " pretend this is xterm. it probably is anyway, but if term is left as - " `screen`, vim doesn't understand ctrl-arrow. - if &term == "screen-256color" - set term=xterm-256color - else - set term=xterm - endif +call plug#begin() +call s:smart_source_rc('plugins') +call plug#end() - " gotta set these *last*, since `set term` resets everything - set t_ts=k - set t_fs=\ - set t_ut= -endif -set title - -" ******************************** -" SET HOTKEYS -" ******************************** - -" Remap jk to esc -inoremap jk -inoremap `` -vnoremap `` - -" Bind Make to F5 like other IDEs -nnoremap :Make! - -" Remap Ctrl+Space for auto Complete -inoremap -inoremap - -" Toggle highlighting with \hr (highlight row) -nnoremap hr :set cursorline! - -" Toggle Line numbers with Ctrl+N double tap -nmap :set invnumber -nmap ln :set invnumber - -" Toggle line wrap with Ctrl+L double tap -nmap :set wrap! -nmap lw :set wrap! - -" Toggle White Space -nmap ws :set list! - -" Map Shift+U to redo -nnoremap - -" Stupid shift key fixes -cmap WQ wq -cmap Wq wq -cmap W w -cmap Q q -cmap Q! q! -" Stupid semicolon files -cnoremap w; w -cnoremap W; w -cnoremap q; q -cnoremap Q; q -" Avoid accidental Ex-mode -:map Q - -" Clearing highlighted search -nmap / :set hlsearch! hlsearch? -noremap :set hlsearch! hlsearch? -" Clear search -nmap cs :nohlsearch - -" Code fold -nmap cf va{zf%:nohlsearch - -" Paste over -vnoremap pp p -vnoremap po "_dP - -" Buffer nav -nmap gb :bn -nmap gB :bp - -set notitle - -" Easy update tags -command TagsUpdate Dispatch ctags -R . - -" Command to display TODO tags in project -command Todo Ag! TODO - -au BufRead,BufNewFile *.md set syntax=markdown - -" ******************************** -" PLUGIN SETTINGS -" ******************************** - -" Airline config -" Use short-form mode text -let g:airline_mode_map = { - \ '__' : '-', - \ 'n' : 'N', - \ 'i' : 'I', - \ 'R' : 'R', - \ 'c' : 'C', - \ 'v' : 'V', - \ 'V' : 'V', - \ '' : 'V', - \ 's' : 'S', - \ 'S' : 'S', - \ '' : 'S', - \ } -let g:airline#extensions#whitespace#trailing_format = 'tw[%s]' -let g:airline#extensions#whitespace#mixed_indent_format = 'i[%s]' -let g:airline_left_sep='' -let g:airline_left_alt_sep='' -let g:airline_right_sep='' -let g:airline_right_alt_sep='' -let g:airline#extensions#tabline#enabled = 1 -let g:airline#extensions#tabline#left_sep = ' ' -let g:airline#extensions#tabline#left_alt_sep = '|' - -" AbuseTheForce -" Set foreground if using tmux, otherwise background -if ! exists('g:abusetheforce_dispatch_background') && (exists("$TMUX") || ( has("gui_running") && has("gui_macvim") ) ) - let g:abusetheforce_dispatch_background = 0 -else - let g:abusetheforce_dispatch_background = 1 -endif - -" Buffet shortcut -nnoremap :Bufferlist - -" NERDTree -" nnoremap :NERDTreeToggle -"nnoremap nn :NERDTreeToggle -"nnoremap nf :NERDTreeFind - -" TComment -nnoremap // :TComment -vnoremap // :TCommentBlock - -" PreserveNoEOL -let g:PreserveNoEOL = 1 - -" CTags List -nnoremap :TagbarToggle -" Autofocus tagbar -let g:tagbar_autofocus = 1 - -" CtrlP settings -" Ensure max height isn't too large. (for performance) -let g:ctrlp_max_height = 10 -" Conditional Mappings -let g:ctrlp_map = '' -" Allow ctrl p to open over the initial nerdtree window -let g:ctrlp_dont_split = 'netrw' -" Support tag jumping -let g:ctrlp_extensions = ['tag', 'buffertag'] -" Support Apex language -let g:ctrlp_buftag_types = { - \ 'apex' : '--language-force=c#', - \ 'go' : { - \ 'bin' : 'gotags', - \ 'args' : '-sort -silent', - \} - \} -" Leader Commands -nnoremap b :CtrlPBuffer -nnoremap t :CtrlPBufTag -nnoremap r :CtrlPTag -nnoremap u :CtrlPCurFile -nnoremap m :CtrlPMRUFiles - -" Special stuff for The Silver Searcher -if executable('ag') - " use ag - set grepprg=ag\ --nogroup\ --nocolor - " use ag for CtrlP - let g:ctrlp_user_command = 'ag %s -l --nocolor --nogroup -g ""' - " ag is fast enough we don't need cache - let g:ctrlp_use_caching = 0 -endif - -" fugitive -" Add some shortcuts for git commands -nnoremap gb :Gblame -nnoremap gc :Gcommit -nnoremap gd :Gdiff -nnoremap gs :Gstatus -nnoremap gw :Gwrite - -" Toggle QuickFix window -nnoremap :QFix - -" neocomplete / neocomplcache -if has('lua') - let g:acp_enableAtStartup = 0 - let g:neocomplete#enable_at_startup = 1 - "let g:neocomplete#enable_smart_case = 1 - let g:neocomlete#max_list=10 -else - " NeoComplCache - let g:neocomplcache_enable_at_startup = 1 - "let g:neocomplcache_enable_smart_case = 1 - let g:neocomplcache_max_list = 10 - "let g:neocomplcache_enable_camel_case_completion = 1 - let g:neocomplcache_enable_fuzzy_completion = 1 - if !exists('g:neocomplcache_force_omni_patterns') - let g:neocomplcache_force_omni_patterns = {} - endif - let g:neocomplcache_force_omni_patterns.python = - \ '\%([^. \t]\.\|^\s*@\|^\s*from\s.\+import \|^\s*from \|^\s*import \)\w*' - " alternative pattern: '\h\w*\|[^. \t]\.\w*' -endif -" -" Enable omni completion. -autocmd FileType css setlocal omnifunc=csscomplete#CompleteCSS -autocmd FileType html,markdown setlocal omnifunc=htmlcomplete#CompleteTags -autocmd FileType javascript setlocal omnifunc=javascriptcomplete#CompleteJS -" Skip python because we have jedi-vim -"autocmd FileType python setlocal omnifunc=pythoncomplete#Complete -autocmd FileType python setlocal omnifunc=jedi#completions -autocmd FileType ruby setlocal omnifunc=rubycomplete#Complete -autocmd FileType xml setlocal omnifunc=xmlcomplete#CompleteTags - - -nmap a :Ag -nmap i* :Ag-i'\b\b' -nmap * :Ag'\b\b' - -" Syntastic settings -let g:syntastic_html_tidy_ignore_errors = [ - \ 'proprietary attribute "ng-show"', - \ 'proprietary attribute "ng-controller"', - \ 'proprietary attribute "ng-repeat"', - \ 'proprietary attribute "ng-app"', - \ 'proprietary attribute "ng-click"' -\ ] -let g:syntastic_python_checkers = ['flake8'] -let g:syntastic_python_flake8_args='--max-line-length=80' -" let g:syntastic_python_checkers = ['pep8'] -" let g:syntastic_python_pep8_args='--ignore=E501' -" let g:syntastic_python_checkers = ['jshint'] -" let g:syntastic_javascript_jshint_args='--ignore=E501' - -" Pymode -let g:pymode_lint = 1 -let g:pymode_lint_on_write = 0 -let g:pymode_lint_checkers = ['flake8'] -let g:pymode_rope = 0 -let g:pymode_rope_completion = 0 -let g:pymode_rope_complete_on_dot = 0 -let g:pymode_breakpoint = 0 - -" jedi-vim -let g:jedi#completions_enabled = 0 -let g:jedi#auto_vim_configuration = 0 +call s:smart_source_rc('edit') +call s:smart_source_rc('keymap') +call s:smart_source_rc('ui')