helm/vimrc

481 lines
16 KiB
VimL
Raw Normal View History

2014-07-21 00:06:01 -07:00
set nocompatible
2014-11-18 20:52:19 -08:00
let g:is_ssh = ($SSH_TTY != "")
2014-07-21 00:06:01 -07:00
" Initialize NeoBundle
set rtp+=~/.vim/bundle/neobundle.vim/
2014-11-18 20:52:19 -08:00
call neobundle#begin(expand('~/.vim/bundle'))
2014-07-21 00:06:01 -07:00
NeoBundleFetch 'Shougo/neobundle.vim'
" Preferences {{{
syntax on
" Editor looks {{{
" Disable matchit, I find it distracting
let loaded_matchparen = 1
if &t_Co == 8 && $TERM !~# '^linux'
set t_Co=16
else
set t_Co=256
endif
set background=dark
colorscheme Tomorrow-Night-Eighties
set number " Line numbers
set showcmd " Show command issued
set fillchars=vert
set list
set listchars=tab:>\ ,trail:-,extends:>,precedes:<,nbsp:+
set textwidth=88
set synmaxcol=1500
" }}}
" Behavior {{{
2014-12-13 16:35:07 -08:00
set noeol
2014-07-21 00:06:01 -07:00
set autoread " Auto-update a file that's been edited externally
set nospell " No spell check, please
set visualbell " No sounds!
set backspace=indent,eol,start
set lazyredraw " Don't update screen while running macros
set hidden " Hide abandoned buffers
set shortmess+=filmnrxoOtTs
set nrformats-=octal
set fileformats+=mac
set mouse=a
if exists('$TMUX') " Support resizing in tmux
set ttymouse=xterm2
endif
" }}}
" StatusBar {{{
if has('statusline')
set laststatus=2
set ruler " Show line/col no in statusline
set statusline=%t " tail of the filename
set statusline+=%w%h%m%r " Options
if exists('g:loaded_syntastic_plugin')
set statusline+=\ %{SyntasticStatuslineFlag()}
endif
set statusline+=%= " left/right separator
set statusline+=%y " filetype
if exists('g:loaded_fugitive')
set statusline+=\ %{fugitive#statusline()} " Git Hotness
endif
2014-12-13 16:35:07 -08:00
set statusline+=\ •\
2014-07-21 00:06:01 -07:00
set statusline+=%c " cursor column
set statusline+=\ %l/%L " cursor line/total lines
set statusline+=\ \:%P " percent through file
endif
" }}}
" Movement & search {{{
set nostartofline
set sidescrolloff=5
set incsearch " find as you type
set hlsearch " Highlight search terms
set ignorecase " case insensitive search
set smartcase " case sensitive when uc present
set gdefault " global flag for substitute by default
if executable('ag')
let g:ackprg = 'ag --nogroup --nocolor --column'
set grepprg=ag\ --nogroup\ --nocolor
elseif executable('ack-grep')
let g:ackprg = "ack-grep -H --nocolor --nogroup --column"
endif
" }}}
" Text formatting {{{
set autoindent
set shiftround
set expandtab
set shiftwidth=4
set tabstop=4
set softtabstop=4
" Wrapping
set nowrap
" Backspace and cursor keys to wrap
set whichwrap=b,s,h,l,<,>,[,]
" see :h fo-table
set formatoptions=qrn1lr
" }}}
" Folding {{{
set foldlevel=1
" Cleaner, readable fold headers
set foldtext=MyFoldText()
fu! MyFoldText()
let line = getline(v:foldstart)
" Lines that have been folded
let nl = v:foldend - v:foldstart + 1
let indent = repeat(' ', indent(v:foldstart))
let endcol = &colorcolumn ? &colorcolumn : &textwidth
let startcol = &columns < endcol ? &columns-4 : endcol
return indent . substitute(line,"^ *","",1)
endf
" }}}
" Swap files, history & persistence {{{
" No backup (that's what git is for!) and swapfiles are annoying
set nobackup
set nowritebackup
set noswapfile
if has('persistent_undo')
set undodir=~/.vim/tmp/undo
set undolevels=500
set undoreload=500
endif
set history=5000
" Preserve buffer state (cursor location, folds, etc.)
set viewdir=~/.vim/tmp/views
set viewoptions=cursor,folds,unix,slash
augroup persistence
au!
au BufWinLeave * if expand("%") != "" | silent! mkview | endif
au BufWinEnter * if expand("%") != "" | silent! loadview | endif
augroup END
" }}}
" Omnicomplete + wild settings {{{
2014-12-13 16:35:07 -08:00
set tags=./tags,./../tags,./../../tags,./../../../tags,tags
2014-07-21 00:06:01 -07:00
set complete-=i
set completeopt=menu
set wildmenu " Show menu instead of auto-complete
set wildmode=list:longest,full " command <Tab> completion: list
" matches -> longest common -> then
" all.
set wildignore+=*.swp,*.log,.sass-cache,.codekit-cache,config.codekit
set wildignore+=*.class,*.o,*.pyc,*.obj,*DS_Store*
" }}}
" Automatically close the popup menu / preview window
au InsertLeave * if pumvisible() == 0|silent! pclose|endif
" Set *.scss to ft=scss instead of css.scss
au BufRead,BufNewFile *.scss set filetype=scss
2014-12-13 16:35:07 -08:00
au BufRead,BufNewFile Cask set filetype=lisp
2014-07-21 00:06:01 -07:00
" }}}
2014-07-29 14:46:52 -07:00
"""""""""""""""""""""""""""""""""""""""""
" Packages/Bundles and their settings "
"""""""""""""""""""""""""""""""""""""""""
" {{{
2014-12-13 16:35:07 -08:00
"NeoBundle 'justinmk/vim-sneak'
NeoBundle 'goldfeld/vim-seek'
2014-07-29 14:46:52 -07:00
" File search {{{
" More powerful file searching
if executable('ag')
NeoBundle 'rking/ag.vim'
elseif executable('ack')
NeoBundle 'mileszs/ack.vim'
endif
" Project-wide search and replace
" NeoBundle 'skwp/greplace.vim'
2014-12-13 16:35:07 -08:00
2014-08-12 22:17:39 -07:00
NeoBundle 'christoomey/vim-tmux-navigator'
2014-07-29 14:46:52 -07:00
" Netrw improvements
NeoBundle 'scrooloose/nerdtree'
let NERDTreeMinimalUI = 1
let NERDTreeChDirMode = 2
" let NERDTreeBookmarksFile = "$HOME/.vim/tmp/NERDtreeBookmarks"
let NERDTreeIgnore = ['\~$', '\.swo$', '\.swp$', '\.git$', '\.hg', '\.svn', '\.bzr', '\.settings', '\.project', '\.DS_Store']
let NERDTreeShowHidden = 1
" Command-T, Peepopen or Goto-anything, but for vim, written in VimL
NeoBundle 'kien/ctrlp.vim'
" Ctrlp extension for jumping to functions
NeoBundle 'tacahiroy/ctrlp-funky'
" Ctrlp extension for listing git modified files
NeoBundle 'jasoncodes/ctrlp-modified.vim'
let g:ctrlp_extensions = ['tag', 'buffertag', 'funky']
" let g:ctrlp_max_height = 10
let g:ctrlp_cache_dir = "~/.vim/tmp/ctrlp"
let g:ctrlp_custom_ignore = {
\ 'dir': '\.(git|hg|svn|settings)$|tmp$',
\ 'file': '\.(exe|so|dll|sass-cache|classpaths|project|cache|jpg|png|gif|swf)$'
\ }
let g:ctrlp_user_command = 'ag %s -l --nocolor -g ""'
let g:ctrlp_match_window = 'bottom,order:btt,min:10,max:10,results:10'
2014-11-18 20:52:19 -08:00
" Smarter buffer/tab navigation
NeoBundle "szw/vim-ctrlspace"
let g:ctrlspace_use_tabline = 1
2014-07-29 14:46:52 -07:00
" }}}
" Editing {{{
" Extended visual mode commands, substitutes and searches
NeoBundle 'vis'
" Auto-closes delimiters like (),{},[],etc.
NeoBundle 'Raimondi/delimitMate'
let g:delimitMate_expand_cr = 1
let g:delimitMate_expand_space = 1
" HTML & CSS emmet goodness; Zen coding's successor
NeoBundle 'mattn/emmet-vim'
" Clean way to close buffers without altering window layout
NeoBundle 'moll/vim-bbye'
" For aligning text
NeoBundle 'godlygeek/tabular'
" Comment out code with native comment syntax
NeoBundle 'tomtom/tcomment_vim'
let g:tcomment_types = {'blade': '{-- %s --}', 'twig': '{# %s #}'}
2014-12-13 16:35:07 -08:00
" Offers some plugins better compatibility with repeat ('.')
2014-07-29 14:46:52 -07:00
NeoBundle 'tpope/vim-repeat'
" Easy changing and insertion of surrounding delimiters (e.g. quotes,
" parenthesis, etc.)
NeoBundle 'tpope/vim-surround'
" Snippets system
2015-06-11 14:21:24 -07:00
" if has("python")
" NeoBundle 'SirVer/ultisnips'
2014-07-29 14:46:52 -07:00
" My snippets
2015-06-11 14:21:24 -07:00
" NeoBundle 'hlissner/vim-ultisnips-snippets'
" endif
2014-07-29 14:46:52 -07:00
" One-key switching between true/false, yes/no, etc
NeoBundle 'AndrewRadev/switch.vim'
" }}}
" Remote resources {{{
" Visual git diffs in the gutter
NeoBundle 'airblade/vim-gitgutter'
let g:gitgutter_realtime = 0
let g:gitgutter_eager = 0
" }}}
" Programming {{{
" Running code inline for testing purposes
NeoBundle 'notalex/vim-run-live'
2014-11-18 20:52:19 -08:00
if !g:is_ssh
" YCM's trouble to get working across systems, so let's
" just leave it to the systems running (mac|g)vim
if has("gui_running")
" Awesome autocompletion
NeoBundle 'Valloric/YouCompleteMe', {'build': {
\ 'mac': './install.sh --clang-completer --system-libclang',
\ 'unix': './install.sh --clang-completer' }}
" let g:ycm_autoclose_preview_window_after_insertion = 1
let g:ycm_confirm_extra_conf = 1
" let g:ycm_register_as_syntastic_checker = 1
" let g:ycm_seed_identifiers_with_syntax = 0
" let g:ycm_add_preview_to_completeopt = 1
let g:ycm_global_ycm_extra_conf = "~/.ycm_extra_conf.py"
" let g:ycm_auto_trigger = 0
let g:ycm_confirm_extra_conf = 0
endif
" Syntax checkers for a multitude of languages
NeoBundle 'scrooloose/syntastic'
let g:syntastic_auto_loc_list=0
" let g:syntastic_quiet_messages={'level': 'warnings'}
let g:syntastic_phpcs_disable=1
let g:syntastic_echo_current_error=1
let g:syntastic_enable_balloons = 0
let g:syntastic_error_symbol = '►'
let g:syntastic_warning_symbol = '►'
let g:syntastic_loc_list_height = 5
let g:syntastic_mode_map = {'mode': 'active', 'active_filetypes': [], 'passive_filetypes': ['html']}
endif
2014-07-29 14:46:52 -07:00
" }}}
" Syntax {{{
" CSS/SCSS/LESS
NeoBundle 'cakebaker/scss-syntax.vim'
" PHP
NeoBundleLazy 'StanAngeloff/php.vim', {'autoload': {'filetypes': ['php', 'blade']}}
NeoBundleLazy '2072/PHP-Indenting-for-VIm', {'autoload': {'filetypes': ['php']}}
" NeoBundleLazy 'stephpy/vim-phpdoc', {'autoload': {'filetypes': ['php']}}
" Python
NeoBundleLazy 'klen/python-mode', {'autoload': {'filetypes': ['python']}}
" Javascript/Node
NeoBundleLazy 'pangloss/vim-javascript', {'autoload': {'filetypes': ['javascript']}}
" Other
NeoBundle 'tpope/vim-markdown'
" }}}
2014-11-18 20:52:19 -08:00
call neobundle#end()
2014-07-29 14:46:52 -07:00
filetype indent plugin on
" }}}
"""""""""""""""""
" Keymappings "
"""""""""""""""""
" {{{
2014-12-13 16:35:07 -08:00
nnoremap <leader>E :CtrlP ~/.dotfiles<CR>
2014-07-29 14:46:52 -07:00
" Comma get some... sorry.
let mapleader = ','
let maplocalleader = '\'
noremap ; :
" Trigger to preserve indentation on pastes
set pastetoggle=<F12>
" Easier than escape. Pinnacle of laziness.
imap jk <ESC>
" Turn off search highlighting
noremap <silent> <leader>? :nohlsearch<CR>
2014-12-13 16:35:07 -08:00
" Emacs-esque escape
inoremap <C-g> <C-[>
2014-07-29 14:46:52 -07:00
" Navigation {{{
" Normalize all the navigation keys to move by row/col despite any wrapped text
noremap j gj
noremap k gk
" % matchit shortcut, but only in normal mode!
nmap <Tab> %
" Easier fold toggle
2014-08-12 22:17:39 -07:00
nnoremap <M-j> 5j
vnoremap <M-j> 5j
nnoremap <M-k> 5k
vnoremap <M-k> 5k
2014-07-29 14:46:52 -07:00
" f: Find. Also support repeating with .
nnoremap <Plug>OriginalSemicolon ;
nnoremap <silent> f :<C-u>call repeat#set("\<lt>Plug>OriginalSemicolon")<CR>f
nnoremap <silent> t :<C-u>call repeat#set("\<lt>Plug>OriginalSemicolon")<CR>t
nnoremap <silent> F :<C-u>call repeat#set("\<lt>Plug>OriginalSemicolon")<CR>F
nnoremap <silent> T :<C-u>call repeat#set("\<lt>Plug>OriginalSemicolon")<CR>T
" }}}
" Editing {{{
nnoremap <C-b> <C-^>
" Insert-mode navigation
" Go to end of line
inoremap <C-e> <Esc>A
" Go to start of line
inoremap <C-a> <Esc>I
" Make Y act consistant with C and D
nnoremap Y y$
" Don't leave visual mode after indenting
vnoremap < <gv
vnoremap > >gv
" Textmate-like CMD+Enter (O in insert mode)
inoremap <S-CR> <C-O>o
inoremap <C-S-CR> <C-O>O
" Enabling repeat in visual mode
vmap . :normal .<CR>
" }}}
" Buffers {{{
" Change CWD to current file's directory
2014-12-13 16:35:07 -08:00
nnoremap <leader>cd :cd %:p:h<cr>:pwd<cr>
2014-07-29 14:46:52 -07:00
" Next/prev buffer
nnoremap ]b :<C-u>bnext<CR>
nnoremap [b :<C-u>bprevious<CR>
" }}}
" Command {{{
" Annoying command mistakes <https://github.com/spf13/spf13-vim>
com! -bang -nargs=* -complete=file E e<bang> <args>
com! -bang -nargs=* -complete=file W w<bang> <args>
com! -bang -nargs=* -complete=file Wq wq<bang> <args>
com! -bang -nargs=* -complete=file WQ wq<bang> <args>
com! -bang Wa wa<bang>
com! -bang WA wa<bang>
com! -bang Q q<bang>
com! -bang QA qa<bang>
com! -bang Qa qa<bang>
" Forget to sudo?
com! WW w !sudo tree % >/dev/null
" Shortcuts
cnoremap ;/ <C-R>=expand('%:p:h').'/'<CR>
cnoremap ;; <C-R>=expand("%:t")<CR>
cnoremap ;. <C-R>=expand("%:p:r")<CR>
2014-12-13 16:35:07 -08:00
2014-07-29 14:46:52 -07:00
" Mimic shortcuts in the terminal
cnoremap <C-a> <Home>
cnoremap <C-e> <End>
" }}}
" External Tools {{{
" Send cwd to tmux
nnoremap <localleader>x :Tmux cd <C-r>=expand("%:p:h")<CR><CR>
nnoremap <localleader>X :Tmux cd <C-r>=expand("%:p:r")<CR><CR>
" }}}
2014-07-21 00:06:01 -07:00
2014-07-29 14:46:52 -07:00
" Plugins {{{
" bufkill
nnoremap zz :Bdelete<CR>
2014-07-21 00:06:01 -07:00
2014-07-29 14:46:52 -07:00
" CtrlP
let g:ctrlp_map = ''
" Only open CtrlP if the cwd ISN'T $HOME
nnoremap <silent><expr> <leader>/ getcwd() != $HOME ? ":<C-u>CtrlPCurWD<CR>" : ":<C-u>echoe 'Cannot open CtrlP in HOME'<CR>"
nnoremap <silent> <leader>. :CtrlPCurFile<CR>
nnoremap <silent> <leader>, :CtrlPBuffer<CR>
nnoremap <silent> <leader>; :CtrlPFunky<CR>
nnoremap <silent> <leader>m :CtrlPMRU<CR>
nnoremap <silent> <leader>M :CtrlPModified<CR>
nnoremap <silent> <leader>t :CtrlPBufTag<CR>
nnoremap <silent> <leader>T :CtrlPBufTagAll<CR>
" NERDTree
map <localleader>\ :NERDTreeCWD<CR>
map <localleader>. :NERDTreeFind<CR>
" Tabularize
nmap <leader>= :Tabularize /
" UltiSnips
let g:UltiSnipsExpandTrigger = "<Tab>"
let g:UltiSnipsJumpForwardTrigger = "<Tab>"
let g:UltiSnipsJumpBackwardTrigger = "<S-Tab>"
" Ignore the default snippets so I (and others) can define their own
let g:UltiSnipsSnippetDirectories = ["snips"]
2014-12-13 16:35:07 -08:00
2014-07-29 14:46:52 -07:00
" Emmet
imap <expr> <C-CR> emmet#expandAbbrIntelligent("\<tab>")
" YCM
map g] :YcmCompleter GoToDefinitionElseDeclaration<CR>
let g:ycm_key_list_select_completion = ['<C-j>', '<Down>']
let g:ycm_key_list_previous_completion = ['<C-k>', '<Up>']
" vim-switch
nnoremap ! :Switch<CR>
" }}}
" }}}
2014-07-21 00:06:01 -07:00
2014-12-13 16:35:07 -08:00
"""""""""""""""""""""""
" Language settings "
"""""""""""""""""""""""
" {{{
" 2-space indentation
autocmd FileType ruby setl ts=2 sw=2 sts=2 et
" }}}
2014-07-21 00:06:01 -07:00
" vim:set fdl=0 fdm=marker: