Move vim settings out of plugins to ensure they all get correctly loaded after everything else [Fix #373]

This commit is contained in:
Yan Pritzker
2013-10-21 16:10:40 -05:00
parent 65a3ec3219
commit 46946c9b8b
55 changed files with 15 additions and 8 deletions

View File

@@ -0,0 +1,4 @@
" Auto open nerd tree on startup
let g:nerdtree_tabs_open_on_gui_startup = 0
" Focus in the main content window
let g:nerdtree_tabs_focus_on_files = 1

View File

@@ -0,0 +1,4 @@
" Make nerdtree look nice
let NERDTreeMinimalUI = 1
let NERDTreeDirArrows = 1
let g:NERDTreeWinSize = 30

9
vim/settings/README.md Normal file
View File

@@ -0,0 +1,9 @@
This directory contains settings for various vim plugins and vim itself.
## Plugin Settings
Each plugin's overrides/settings should be put in a separate file named `{plugin-name}.vim`.
## Vim Settings
General vim overrides/settings should be put in a separate file named `yadr-{descriptive-name}.vim`.

9
vim/settings/abbr.vim Normal file
View File

@@ -0,0 +1,9 @@
"Abbreviations, trigger by typing the abbreviation and hitting space
abbr rlb Rails.logger.banner
abbr rld Rails.logger.debug
abbr pry! require 'pry'; binding.pry
abbr cl! console.log( )<left><left>
" Rspec Before
abbr rbf before { }<left><left>

7
vim/settings/airline.vim Normal file
View File

@@ -0,0 +1,7 @@
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_branch_prefix = '⭠ '
let g:airline_readonly_symbol = '⭤'
let g:airline_linecolumn_prefix = '⭡'

3
vim/settings/autotag.vim Normal file
View File

@@ -0,0 +1,3 @@
" AutoTag
" Seems to have problems with some vim files
let g:autotagExcludeSuffixes="tml.xml.text.txt.vim"

View File

@@ -0,0 +1,7 @@
map W <Plug>CamelCaseMotion_w
map B <Plug>CamelCaseMotion_b
map E <Plug>CamelCaseMotion_e
sunmap W
sunmap B
sunmap E

View File

@@ -0,0 +1,10 @@
let g:ConqueTerm_InsertOnEnter = 0
let g:ConqueTerm_CWInsert = 1
let g:ConqueTerm_Color = 2
let g:ConqueTerm_ReadUnfocused = 1 " update conqueterm buffer while we're not looking (for running tests)
" Open up a variety of commands in the ConqueTerm
nmap <silent> <Leader>cc :execute 'ConqueTermSplit script/console --irb=pry'<CR>
nmap <silent> <Leader>pp :execute 'ConqueTermSplit pry'<CR>
let g:ConqueTerm_SendVisKey = '<Leader>e'

40
vim/settings/ctrlp.vim Normal file
View File

@@ -0,0 +1,40 @@
let g:ctrlp_custom_ignore = '\.git$\|\.hg$\|\.svn$'
let g:ctrlp_user_command = ['.git', 'cd %s && git ls-files . --cached --exclude-standard --others']
" Default to filename searches - so that appctrl will find application
" controller
let g:ctrlp_by_filename = 1
" We don't want to use Ctrl-p as the mapping because
" it interferes with YankRing (paste, then hit ctrl-p)
let g:ctrlp_map = ',t'
nnoremap <silent> ,t :CtrlP<CR>
" Additional mapping for buffer search
nnoremap <silent> ,b :CloseSingleConque<CR>:CtrlPBuffer<cr>
nnoremap <silent> <C-b> :CloseSingleConque<CR>:CtrlPBuffer<cr>
" Cmd-Shift-P to clear the cache
nnoremap <silent> <D-P> :ClearCtrlPCache<cr>
" Idea from : http://www.charlietanksley.net/blog/blog/2011/10/18/vim-navigation-with-lustyexplorer-and-lustyjuggler/
" Open CtrlP starting from a particular path, making it much
" more likely to find the correct thing first. mnemonic 'jump to [something]'
map ,ja :CloseSingleConque<CR>:CtrlP app/assets<CR>
map ,jm :CloseSingleConque<CR>:CtrlP app/models<CR>
map ,jc :CloseSingleConque<CR>:CtrlP app/controllers<CR>
map ,jv :CloseSingleConque<CR>:CtrlP app/views<CR>
map ,jh :CloseSingleConque<CR>:CtrlP app/helpers<CR>
map ,jl :CloseSingleConque<CR>:CtrlP lib<CR>
map ,jp :CloseSingleConque<CR>:CtrlP public<CR>
map ,js :CloseSingleConque<CR>:CtrlP spec<CR>
map ,jf :CloseSingleConque<CR>:CtrlP fast_spec<CR>
map ,jd :CloseSingleConque<CR>:CtrlP db<CR>
map ,jC :CloseSingleConque<CR>:CtrlP config<CR>
map ,jV :CloseSingleConque<CR>:CtrlP vendor<CR>
map ,jF :CloseSingleConque<CR>:CtrlP factories<CR>
map ,jT :CloseSingleConque<CR>:CtrlP test<CR>
"Cmd-Shift-(M)ethod - jump to a method (tag in current file)
"Ctrl-m is not good - it overrides behavior of Enter
nnoremap <silent> <D-M> :CloseSingleConque<CR>:CtrlPBufTag<CR>

View File

@@ -0,0 +1,21 @@
" This remaps easymotion to show us only the left
" hand home row keys as navigation options which
" may mean more typing to get to a particular spot
" but it'll all be isolated to one area of the keyboard
call EasyMotion#InitOptions({
\ 'leader_key' : '<Leader><Leader>'
\ , 'keys' : 'fjdksewoavn'
\ , 'do_shade' : 1
\ , 'do_mapping' : 1
\ , 'grouping' : 1
\
\ , 'hl_group_target' : 'Question'
\ , 'hl_group_shade' : 'EasyMotionShade'
\ })
" Make EasyMotion more yellow, less red
hi clear EasyMotionTarget
hi! EasyMotionTarget guifg=yellow
nmap ,<ESC> ,,w
nmap ,<S-ESC> ,,b

View File

@@ -0,0 +1,5 @@
" fugitive.git
" ========================================
" For fugitive.git, dp means :diffput. Define dg to mean :diffget
nnoremap <silent> ,dg :diffget<CR>
nnoremap <silent> ,dp :diffput<CR>

View File

@@ -0,0 +1,6 @@
" Support for github flavored markdown
" via https://github.com/jtratner/vim-flavored-markdown
augroup markdown
au!
au BufNewFile,BufRead *.md,*.markdown setlocal filetype=ghmarkdown
augroup END

24
vim/settings/git-grep.vim Normal file
View File

@@ -0,0 +1,24 @@
"git grep the current word using K (mnemonic Kurrent)
nnoremap <silent> K :call CloseSingleConque()<CR>:GitGrep <cword><CR>
function! GetVisual()
let reg_save = getreg('"')
let regtype_save = getregtype('"')
let cb_save = &clipboard
set clipboard&
normal! ""gvy
let selection = getreg('"')
call setreg('"', reg_save, regtype_save)
let &clipboard = cb_save
return selection
endfunction
"git grep visual selection
vnoremap K :call CloseSingleConque()<CR>:<C-U>execute GitGrep(GetVisual())<CR>
"git grep current word up to the next exclamation point using ,K
nnoremap ,K viwf!:<C-U>execute GitGrep(GetVisual())<CR>
"grep for 'def foo'
nnoremap <silent> ,gd :GitGrep 'def <cword>'<CR>

View File

@@ -0,0 +1,7 @@
" Automatically jump to a file at the correct line number
" i.e. if your cursor is over /some/path.rb:50 then using 'gf' on it will take
" you to that line
" use ,gf to go to file in a vertical split
nnoremap <silent> ,gf :vertical botright wincmd F<CR>
nnoremap <silent> <C-F> :vertical botright wincmd F<CR>

2
vim/settings/grep.vim Normal file
View File

@@ -0,0 +1,2 @@
"Use the silver searcher for lightning fast Gsearch command
set grepprg=ag

7
vim/settings/gundo.vim Normal file
View File

@@ -0,0 +1,7 @@
nmap ,u :GundoToggle<CR>
" open on the right so as not to compete with the nerdtree
let g:gundo_right = 1
" a little wider for wider screens
let g:gundo_width = 60

1
vim/settings/jquery.vim Normal file
View File

@@ -0,0 +1 @@
autocmd BufRead,BufNewFile *.js set ft=javascript syntax=jquery

View File

@@ -0,0 +1,3 @@
let g:LustyJugglerSuppressRubyWarning = 1
let g:LustyJugglerAltTabMode = 1
let g:LustyJugglerShowKeys = 'a' " show a/s/d/f keys

View File

@@ -0,0 +1,42 @@
" neocomplcache
" A beter autocomplete system!
let g:neocomplcache_enable_at_startup = 1
let g:neocomplcache_enable_camel_case_completion = 1
let g:neocomplcache_enable_underbar_completion = 1
let g:neocomplcache_enable_smart_case = 1
" default # of completions is 100, that's crazy
let g:neocomplcache_max_list = 5
" words less than 3 letters long aren't worth completing
let g:neocomplcache_auto_completion_start_length = 3
" Map standard Ctrl-N completion to Cmd-Space
inoremap <D-Space> <C-n>
" This makes sure we use neocomplcache completefunc instead of
" the one in rails.vim, otherwise this plugin will crap out
let g:neocomplcache_force_overwrite_completefunc = 1
" Define keyword.
if !exists('g:neocomplcache_keyword_patterns')
let g:neocomplcache_keyword_patterns = {}
endif
let g:neocomplcache_keyword_patterns['default'] = '\h\w*'
" 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
autocmd FileType python setlocal omnifunc=pythoncomplete#Complete
autocmd FileType xml setlocal omnifunc=xmlcomplete#CompleteTags
autocmd FileType ruby setlocal omnifunc=rubycomplete#Complete
" Enable heavy omni completion.
if !exists('g:neocomplcache_omni_patterns')
let g:neocomplcache_omni_patterns = {}
endif
let g:neocomplcache_omni_patterns.ruby = '[^. *\t]\.\w*\|\h\w*::'
" Prevent hanging with python: https://github.com/skwp/dotfiles/issues/163
let g:neocomplcache_omni_patterns['python'] = ''

View File

@@ -0,0 +1,136 @@
" Stolen from Steve Losh
" https://github.com/sjl/dotfiles/blob/master/vim/vimrc#L1380
"
" Motion for "next/last object". "Last" here means "previous", not "final".
" Unfortunately the "p" motion was already taken for paragraphs.
"
" Next acts on the next object of the given type, last acts on the previous
" object of the given type. These don't necessarily have to be in the current
" line.
"
" Currently works for (, [, {, and their shortcuts b, r, B.
"
" Next kind of works for ' and " as long as there are no escaped versions of
" them in the string (TODO: fix that). Last is currently broken for quotes
" (TODO: fix that).
"
" Some examples (C marks cursor positions, V means visually selected):
"
" din' -> delete in next single quotes foo = bar('spam')
" C
" foo = bar('')
" C
"
" canb -> change around next parens foo = bar('spam')
" C
" foo = bar
" C
"
" vin" -> select inside next double quotes print "hello ", name
" C
" print "hello ", name
" VVVVVV
onoremap an :<c-u>call <SID>NextTextObject('a', '/')<cr>
xnoremap an :<c-u>call <SID>NextTextObject('a', '/')<cr>
onoremap in :<c-u>call <SID>NextTextObject('i', '/')<cr>
xnoremap in :<c-u>call <SID>NextTextObject('i', '/')<cr>
onoremap al :<c-u>call <SID>NextTextObject('a', '?')<cr>
xnoremap al :<c-u>call <SID>NextTextObject('a', '?')<cr>
onoremap il :<c-u>call <SID>NextTextObject('i', '?')<cr>
xnoremap il :<c-u>call <SID>NextTextObject('i', '?')<cr>
function! s:NextTextObject(motion, dir)
let c = nr2char(getchar())
let d = ''
if c ==# "b" || c ==# "(" || c ==# ")"
let c = "("
elseif c ==# "B" || c ==# "{" || c ==# "}"
let c = "{"
elseif c ==# "r" || c ==# "[" || c ==# "]"
let c = "["
elseif c ==# "'"
let c = "'"
elseif c ==# '"'
let c = '"'
else
return
endif
" Find the next opening-whatever.
execute "normal! " . a:dir . c . "\<cr>"
if a:motion ==# 'a'
" If we're doing an 'around' method, we just need to select around it
" and we can bail out to Vim.
execute "normal! va" . c
else
" Otherwise we're looking at an 'inside' motion. Unfortunately these
" get tricky when you're dealing with an empty set of delimiters because
" Vim does the wrong thing when you say vi(.
let open = ''
let close = ''
if c ==# "("
let open = "("
let close = ")"
elseif c ==# "{"
let open = "{"
let close = "}"
elseif c ==# "["
let open = "\\["
let close = "\\]"
elseif c ==# "'"
let open = "'"
let close = "'"
elseif c ==# '"'
let open = '"'
let close = '"'
endif
" We'll start at the current delimiter.
let start_pos = getpos('.')
let start_l = start_pos[1]
let start_c = start_pos[2]
" Then we'll find it's matching end delimiter.
if c ==# "'" || c ==# '"'
" searchpairpos() doesn't work for quotes, because fuck me.
let end_pos = searchpos(open)
else
let end_pos = searchpairpos(open, '', close)
endif
let end_l = end_pos[0]
let end_c = end_pos[1]
call setpos('.', start_pos)
if start_l == end_l && start_c == (end_c - 1)
" We're in an empty set of delimiters. We'll append an "x"
" character and select that so most Vim commands will do something
" sane. v is gonna be weird, and so is y. Oh well.
execute "normal! ax\<esc>\<left>"
execute "normal! vi" . c
elseif start_l == end_l && start_c == (end_c - 2)
" We're on a set of delimiters that contain a single, non-newline
" character. We can just select that and we're done.
execute "normal! vi" . c
else
" Otherwise these delimiters contain something. But we're still not
" sure Vim's gonna work, because if they contain nothing but
" newlines Vim still does the wrong thing. So we'll manually select
" the guts ourselves.
let whichwrap = &whichwrap
set whichwrap+=h,l
execute "normal! va" . c . "hol"
let &whichwrap = whichwrap
endif
endif
endfunction

View File

@@ -0,0 +1,20 @@
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" OpenChangedFiles COMMAND
" Open a split for each dirty file in git
"
" Shamelessly stolen from Gary Bernhardt: https://github.com/garybernhardt/dotfiles
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
function! OpenChangedFiles()
only " Close all windows, unless they're modified
let status = system('git status -s | grep "^ \?\(M\|A\)" | cut -d " " -f 3')
let filenames = split(status, "\n")
if len(filenames) > 0
exec "edit " . filenames[0]
for filename in filenames[1:]
exec "sp " . filename
endfor
end
endfunction
command! OpenChangedFiles :call OpenChangedFiles()
nnoremap ,ocf :OpenChangedFiles<CR>

View File

@@ -0,0 +1,13 @@
" Navigate to the block surrounding this one
" For example if you're inside
" foo do
" bar do
" # you are here
" end
" end
"
" Then hitting ,orb ("outer ruby block") will take you to 'foo do'
"
" This is relying on the textobj-rubyblock which gives us 'ar' around ruby
" and matchit.vim which gives us jumping to the matching
nnoremap <silent> ,orb :normal varar%<esc><esc>

View File

@@ -0,0 +1,7 @@
" persistent undos - undo after you re-open the file
" but this gives warnings under command line vim
" use only in macvim
if v:version > '702'
set undodir=~/.vim/backups
set undofile
endif

View File

@@ -0,0 +1,5 @@
let g:Powerline_symbols='fancy'
let g:Powerline_theme='skwp'
let g:Powerline_colorscheme='skwp'
set laststatus=2 "always show the statusline

View File

@@ -0,0 +1,9 @@
" Stolen from Steve Losh vimrc: https://bitbucket.org/sjl/dotfiles/src/tip/vim/.vimrc
" Open a Quickfix window for the last search.
nnoremap <silent> <leader>q/ :execute 'vimgrep /'.@/.'/g %'<CR>:copen<CR>
" Ag for the last search.
nnoremap <silent> <leader>qa/ :execute "Ag! '" . substitute(substitute(substitute(@/, "\\\\<", "\\\\b", ""), "\\\\>", "\\\\b", ""), "\\\\v", "", "") . "'"<CR>
" GitGrep the last search (my own invention)
nnoremap <silent> <leader>qg/ :execute "GitGrep '" . substitute(substitute(substitute(@/, "\\\\<", "\\\\b", ""), "\\\\>", "\\\\b", ""), "\\\\v", "", "") . "'"<CR>

3
vim/settings/rails.vim Normal file
View File

@@ -0,0 +1,3 @@
" Better key maps for switching between controller and view
nnoremap ,vv :Rview<cr>
nnoremap ,cc :Rcontroller<cr>

26
vim/settings/rspec.vim Normal file
View File

@@ -0,0 +1,26 @@
" Does not work on pending 'blocks', only single lines
"
" Given:
" it "foo bar" do
" pending("bla bla"
"
" Produce:
" xit "foo bar" do
"
function! ChangePendingRspecToXit()
" Find the next occurrence of pending
while(search("pending(") > 0)
" Delete it
normal dd
" Search backwards to the it block
?it\s
" add an 'x' to the 'it' to make it 'xit'
normal ix
endwhile
endfunction
nnoremap <silent> ,rxit :call ChangePendingRspecToXit()<cr>
" insert a before { } block around a line
nnoremap <silent> \bf ^ibefore { <esc>$a }

View File

@@ -0,0 +1,2 @@
" Tell showmarks to not include the various brace marks (),{}, etc
let g:showmarks_include = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXY"

View File

@@ -0,0 +1,6 @@
" hit ,f to find the definition of the current class
" this uses ctags. the standard way to get this is Ctrl-]
nnoremap <silent> ,f <C-]>
" use ,F to jump to tag in a vertical split
nnoremap <silent> ,F :let word=expand("<cword>")<CR>:vsp<CR>:wincmd w<cr>:exec("tag ". word)<cr>

View File

@@ -0,0 +1,68 @@
if !has("gui_macvim")
set t_Co=256
let g:solarized_termcolors=256
endif
hi! link txtBold Identifier
hi! link zshVariableDef Identifier
hi! link zshFunction Function
hi! link rubyControl Statement
hi! link rspecGroupMethods rubyControl
hi! link rspecMocks Identifier
hi! link rspecKeywords Identifier
hi! link rubyLocalVariableOrMethod Normal
hi! link rubyStringDelimiter Constant
hi! link rubyString Constant
hi! link rubyAccess Todo
hi! link rubySymbol Identifier
hi! link rubyPseudoVariable Type
hi! link rubyRailsARAssociationMethod Title
hi! link rubyRailsARValidationMethod Title
hi! link rubyRailsMethod Title
hi! link rubyDoBlock Normal
hi! link MatchParen DiffText
hi! link CTagsModule Type
hi! link CTagsClass Type
hi! link CTagsMethod Identifier
hi! link CTagsSingleton Identifier
hi! link javascriptFuncName Type
hi! link javascriptFunction Statement
hi! link javascriptThis Statement
hi! link javascriptParens Normal
hi! link jOperators javascriptStringD
hi! link jId Title
hi! link jClass Title
hi! link NERDTreeFile Constant
hi! link NERDTreeDir Identifier
hi! link sassMixinName Function
hi! link sassDefinition Function
hi! link sassProperty Type
hi! link htmlTagName Type
hi! PreProc gui=bold
" Solarized separators are a little garish.
" This moves separators, comments, and normal
" text into the same color family as the background.
" Using the http://drpeterjones.com/colorcalc/,
" they are now just differently saturated and
" valued riffs on the background color, making
" everything play together just a little more nicely.
hi! VertSplit guifg=#003745 cterm=NONE term=NONE ctermfg=NONE ctermbg=NONE
hi! LineNR guifg=#004C60 gui=bold guibg=#002B36 ctermfg=146
hi! link NonText VertSplit
hi! Normal guifg=#77A5B1
hi! Constant guifg=#00BCE0
hi! Comment guifg=#52737B
hi! link htmlLink Include
hi! CursorLine cterm=NONE gui=NONE
hi! Visual ctermbg=233
hi! Type gui=bold
hi! EasyMotionTarget guifg=#4CE660 gui=bold
" Make sure this file loads itself on top of any other color settings
au VimEnter * so ~/.vim/settings/solarized.vim

View File

@@ -0,0 +1,9 @@
" If you visually select something and hit paste
" that thing gets yanked into your buffer. This
" generally is annoying when you're copying one item
" and repeatedly pasting it. This changes the paste
" command in visual mode so that it doesn't overwrite
" whatever is in your paste buffer.
"
vnoremap p "_dP

12
vim/settings/surround.vim Normal file
View File

@@ -0,0 +1,12 @@
" via: http://whynotwiki.com/Vim
" Ruby
" Use v or # to get a variable interpolation (inside of a string)}
" ysiw# Wrap the token under the cursor in #{}
" v...s# Wrap the selection in #{}
let g:surround_113 = "#{\r}" " v
let g:surround_35 = "#{\r}" " #
" Select text in an ERb file with visual mode and then press s- or s=
" Or yss- to do entire line.
let g:surround_45 = "<% \r %>" " -
let g:surround_61 = "<%= \r %>" " =

View File

@@ -0,0 +1,8 @@
"mark syntax errors with :signs
let g:syntastic_enable_signs=1
"automatically jump to the error when saving the file
let g:syntastic_auto_jump=0
"show the error list automatically
let g:syntastic_auto_loc_list=1
"don't care about warnings
let g:syntastic_quiet_warnings=0

View File

@@ -0,0 +1,8 @@
" tComment
" ========================================
" extensions for tComment plugin. Normally
" tComment maps 'gcc' to comment current line
" this adds 'gcp' comment current paragraph (block)
" using tComment's built in <c-_>p mapping
nmap <silent> gcp <c-_>p

3
vim/settings/tagbar.vim Normal file
View File

@@ -0,0 +1,3 @@
"open the taglist (method browser) using ,t
nnoremap <silent> ,T :TagbarToggle<CR>

1
vim/settings/tidy.vim Normal file
View File

@@ -0,0 +1 @@
:vmap ,gt :!tidy -q -i --show-errors 0<CR>

View File

@@ -0,0 +1,10 @@
" https://github.com/carlhuda/janus/blob/master/vimrc
" Unimpaired configuration
" Bubble single lines
nmap <C-Up> [e
nmap <C-Down> ]e
" Bubble multiple lines
vmap <C-Up> [egv
vmap <C-Down> ]egv

View File

@@ -0,0 +1,15 @@
" The tree buffer makes it easy to drill down through the directories of your
" git repository, but its not obvious how you could go up a level to the
" parent directory. Heres a mapping of .. to the above command, but
" only for buffers containing a git blob or tree
autocmd User fugitive
\ if fugitive#buffer().type() =~# '^\%(tree\|blob\)$' |
\ nnoremap <buffer> .. :edit %:h<CR> |
\ endif
" Every time you open a git object using fugitive it creates a new buffer.
" This means that your buffer listing can quickly become swamped with
" fugitive buffers. This prevents this from becomming an issue:
autocmd BufReadPost fugitive://* set bufhidden=delete

View File

@@ -0,0 +1,3 @@
let g:indent_guides_auto_colors = 1
let g:indent_guides_start_level = 2
let g:indent_guides_guide_size = 1

View File

@@ -0,0 +1,12 @@
" Turn off default key mappings
let g:multi_cursor_use_default_mapping=0
" Switch to multicursor mode with Apple-*
let g:multi_cursor_start_key='<D-*>'
" Ctrl-n, Ctrl-p, Ctrl-x, and <Esc> are mapped in the special multicursor
" mode once you've added at least one virtual cursor to the buffer
let g:multi_cursor_next_key='<C-n>'
let g:multi_cursor_prev_key='<C-p>'
let g:multi_cursor_skip_key='<C-x>'
let g:multi_cursor_quit_key='<Esc>'

View File

@@ -0,0 +1,4 @@
" prevent auto insert mode, which is helpful when using conque
" term for running tests
"
autocmd WinEnter * stopinsert

View File

@@ -0,0 +1,20 @@
"Disable default maps which are too aggressive, overriding <leader>t and
"<leader>b
let g:ruby_debugger_no_maps=1
let os=substitute(system('uname'), '\n', '', '')
if os == 'Darwin' || os == 'Mac'
let g:ruby_debugger_progname='mvim'
endif
"Make our own maps
noremap <leader>db :call ruby_debugger#load_debugger() <bar> call g:RubyDebugger.toggle_breakpoint()<CR>
noremap <leader>dv :call ruby_debugger#load_debugger() <bar> call g:RubyDebugger.open_variables()<CR>
noremap <leader>dm :call ruby_debugger#load_debugger() <bar> call g:RubyDebugger.open_breakpoints()<CR>
noremap <leader>dt :call ruby_debugger#load_debugger() <bar> call g:RubyDebugger.open_frames()<CR>
noremap <leader>ds :call ruby_debugger#load_debugger() <bar> call g:RubyDebugger.step()<CR>
noremap <leader>df :call ruby_debugger#load_debugger() <bar> call g:RubyDebugger.finish()<CR>
noremap <leader>dn :call ruby_debugger#load_debugger() <bar> call g:RubyDebugger.next()<CR>
noremap <leader>dc :call ruby_debugger#load_debugger() <bar> call g:RubyDebugger.continue()<CR>
noremap <leader>de :call ruby_debugger#load_debugger() <bar> call g:RubyDebugger.exit()<CR>
noremap <leader>dd :call ruby_debugger#load_debugger() <bar> call g:RubyDebugger.remove_breakpoints()<CR>

View File

@@ -0,0 +1,24 @@
" Make it beautiful - colors and fonts
" http://ethanschoonover.com/solarized/vim-colors-solarized
colorscheme solarized
set background=dark
if has("gui_running")
"tell the term has 256 colors
set t_Co=256
" Show tab number (useful for Cmd-1, Cmd-2.. mapping)
" For some reason this doesn't work as a regular set command,
" (the numbers don't show up) so I made it a VimEnter event
autocmd VimEnter * set guitablabel=%N:\ %t\ %M
set lines=60
set columns=190
set guifont=Inconsolata\ XL:h17,Inconsolata:h20,Monaco:h17
else
"dont load csapprox if we no gui support - silences an annoying warning
let g:CSApprox_loaded = 1
endif

View File

@@ -0,0 +1,13 @@
" If there isn't one, append a semi colon to the end of the current line.
function! s:appendSemiColon()
if getline('.') !~ ';$'
let original_cursor_position = getpos('.')
exec("s/$/;/")
call setpos('.', original_cursor_position)
endif
endfunction
" For programming languages using a semi colon at the end of statement.
autocmd FileType c,cpp,css,java,javascript,perl,php,jade nmap <silent> ;; :call <SID>appendSemiColon()<CR>
autocmd FileType c,cpp,css,java,javascript,perl,php,jade inoremap <silent> ;; <ESC>:call <SID>appendSemiColon()<CR>a

View File

@@ -0,0 +1,6 @@
" Disable the scrollbars (NERDTree)
set guioptions-=r
set guioptions-=L
" Disable the macvim toolbar
set guioptions-=T

View File

@@ -0,0 +1,237 @@
" ========================================
" General vim sanity improvements
" ========================================
"
"
" alias yw to yank the entire word 'yank inner word'
" even if the cursor is halfway inside the word
" FIXME: will not properly repeat when you use a dot (tie into repeat.vim)
nnoremap ,yw yiww
" ,ow = 'overwrite word', replace a word with what's in the yank buffer
" FIXME: will not properly repeat when you use a dot (tie into repeat.vim)
nnoremap ,ow "_diwhp
"make Y consistent with C and D
nnoremap Y y$
function! YRRunAfterMaps()
nnoremap Y :<C-U>YRYankCount 'y$'<CR>
endfunction
" ========================================
" RSI Prevention - keyboard remaps
" ========================================
" Certain things we do every day as programmers stress
" out our hands. For example, typing underscores and
" dashes are very common, and in position that require
" a lot of hand movement. Vim to the rescue
"
" Now using the middle finger of either hand you can type
" underscores with apple-k or apple-d, and add Shift
" to type dashes
imap <silent> <D-k> _
imap <silent> <D-d> _
imap <silent> <D-K> -
imap <silent> <D-D> -
" ,# Surround a word with #{ruby interpolation}
map ,# ysiw#
vmap ,# c#{<C-R>"}<ESC>
" ," Surround a word with "quotes"
map ," ysiw"
vmap ," c"<C-R>""<ESC>
" ,' Surround a word with 'single quotes'
map ,' ysiw'
vmap ,' c'<C-R>"'<ESC>
" ,) or ,( Surround a word with (parens)
" The difference is in whether a space is put in
map ,( ysiw(
map ,) ysiw)
vmap ,( c( <C-R>" )<ESC>
vmap ,) c(<C-R>")<ESC>
" ,[ Surround a word with [brackets]
map ,] ysiw]
map ,[ ysiw[
vmap ,[ c[ <C-R>" ]<ESC>
vmap ,] c[<C-R>"]<ESC>
" ,{ Surround a word with {braces}
map ,} ysiw}
map ,{ ysiw{
vmap ,} c{ <C-R>" }<ESC>
vmap ,{ c{<C-R>"}<ESC>
map ,` ysiw`
" gary bernhardt's hashrocket
imap <c-l> <space>=><space>
" Change inside various enclosures with Cmd-" and Cmd-'
" The f makes it find the enclosure so you don't have
" to be standing inside it
nnoremap <D-'> f'ci'
nnoremap <D-"> f"ci"
nnoremap <D-(> f(ci(
nnoremap <D-)> f)ci)
nnoremap <D-[> f[ci[
nnoremap <D-]> f]ci]
"Go to last edit location with ,.
nnoremap ,. '.
"When typing a string, your quotes auto complete. Move past the quote
"while still in insert mode by hitting Ctrl-a. Example:
"
" type 'foo<c-a>
"
" the first quote will autoclose so you'll get 'foo' and hitting <c-a> will
" put the cursor right after the quote
imap <C-a> <esc>wa
" ==== NERD tree
" Cmd-Shift-N for nerd tree
nmap <D-N> :NERDTreeToggle<CR>
" Open the project tree and expose current file in the nerdtree with Ctrl-\
nnoremap <silent> <C-\> :NERDTreeFind<CR>:vertical res 30<CR>
" ,q to toggle quickfix window (where you have stuff like GitGrep)
" ,oq to open it back up (rare)
nmap <silent> ,qc :CloseSingleConque<CR>:cclose<CR>
nmap <silent> ,qo :copen<CR>
" move up/down quickly by using Cmd-j, Cmd-k
" which will move us around by functions
nnoremap <silent> <D-j> }
nnoremap <silent> <D-k> {
autocmd FileType ruby map <buffer> <D-j> ]m
autocmd FileType ruby map <buffer> <D-k> [m
autocmd FileType rspec map <buffer> <D-j> }
autocmd FileType rspec map <buffer> <D-k> {
autocmd FileType javascript map <buffer> <D-k> }
autocmd FileType javascript map <buffer> <D-j> {
" Command-/ to toggle comments
map <D-/> :TComment<CR>
imap <D-/> <Esc>:TComment<CR>i
"GitGrep - open up a git grep line, with a quote started for the search
nnoremap ,gg :GitGrep ""<left>
"GitGrep Current Partial
nnoremap ,gcp :GitGrepCurrentPartial<CR>
"GitGrep Current File
nnoremap ,gcf :call GitGrep(expand("%:t:r"))<CR>
"Move back and forth through previous and next buffers
"with ,z and ,x
nnoremap <silent> ,z :bp<CR>
nnoremap <silent> ,x :bn<CR>
" ==============================
" Window/Tab/Split Manipulation
" ==============================
" Move between split windows by using the four directions H, L, I, N
" (note that I use I and N instead of J and K because J already does
" line joins and K is mapped to GitGrep the current word
nnoremap <silent> <C-h> <C-w>h
nnoremap <silent> <C-l> <C-w>l
nnoremap <silent> <C-k> <C-w>k
nnoremap <silent> <C-j> <C-w>j
" Zoom in and out of current window with ,gz
map <silent> ,gz <C-w>o
" Use numbers to pick the tab you want (like iTerm)
map <silent> <D-1> :tabn 1<cr>
map <silent> <D-2> :tabn 2<cr>
map <silent> <D-3> :tabn 3<cr>
map <silent> <D-4> :tabn 4<cr>
map <silent> <D-5> :tabn 5<cr>
map <silent> <D-6> :tabn 6<cr>
map <silent> <D-7> :tabn 7<cr>
map <silent> <D-8> :tabn 8<cr>
map <silent> <D-9> :tabn 9<cr>
" Create window splits easier. The default
" way is Ctrl-w,v and Ctrl-w,s. I remap
" this to vv and ss
nnoremap <silent> vv <C-w>v
nnoremap <silent> ss <C-w>s
" Resize windows with arrow keys
nnoremap <D-Up> <C-w>+
nnoremap <D-Down> <C-w>-
nnoremap <D-Left> <C-w><
nnoremap <D-Right> <C-w>>
" create <%= foo %> erb tags using Ctrl-k in edit mode
imap <silent> <C-K> <%= %><Esc>3hi
" create <%= foo %> erb tags using Ctrl-j in edit mode
imap <silent> <C-J> <% %><Esc>2hi
" ============================
" Shortcuts for everyday tasks
" ============================
" copy current filename into system clipboard - mnemonic: (c)urrent(f)ilename
" this is helpful to paste someone the path you're looking at
nnoremap <silent> ,cf :let @* = expand("%:~")<CR>
nnoremap <silent> ,cn :let @* = expand("%:t")<CR>
"Clear current search highlight by double tapping //
nmap <silent> // :nohlsearch<CR>
"(v)im (c)ommand - execute current line as a vim command
nmap <silent> ,vc yy:<C-f>p<C-c><CR>
"(v)im (r)eload
nmap <silent> ,vr :so %<CR>
" Type ,hl to toggle highlighting on/off, and show current value.
noremap ,hl :set hlsearch! hlsearch?<CR>
" These are very similar keys. Typing 'a will jump to the line in the current
" file marked with ma. However, `a will jump to the line and column marked
" with ma. Its more useful in any case I can imagine, but its located way
" off in the corner of the keyboard. The best way to handle this is just to
" swap them: http://items.sjbach.com/319/configuring-vim-right
nnoremap ' `
nnoremap ` '
" ============================
" Tabularize - alignment
" ============================
" Hit Cmd-Shift-A then type a character you want to align by
nmap <D-A> :Tabularize /
vmap <D-A> :Tabularize /
" ============================
" SplitJoin plugin
" ============================
nmap sj :SplitjoinSplit<cr>
nmap sk :SplitjoinJoin<cr>
" ============================
" vim-ruby-conque
" ============================
" Cmd-Shift-R for RSpec
nmap <silent> <D-R> :call RunRspecCurrentFileConque()<CR>
" Cmd-Shift-L for RSpec Current Line
nmap <silent> <D-L> :call RunRspecCurrentLineConque()<CR>
" ,Cmd-R for Last conque command
nmap <silent> ,<D-R> :call RunLastConqueCommand()<CR>
" Get the current highlight group. Useful for then remapping the color
map ,hi :echo "hi<" . synIDattr(synID(line("."),col("."),1),"name") . '> trans<' . synIDattr(synID(line("."),col("."),0),"name") . "> lo<" . synIDattr(synIDtrans(synID(line("."),col("."),1)),"name") . ">" . " FG:" . synIDattr(synIDtrans(synID(line("."),col("."),1)),"fg#")<CR>
" Source current file Cmd-% (good for vim development)
map <D-%> :so %<CR>
" ,hp = html preview
map <silent> ,hp :!open -a Safari %<CR><CR>

View File

@@ -0,0 +1,8 @@
" ================ Search Settings =================
set incsearch " Find the next match as we type the search
set hlsearch " Hilight searches by default
set viminfo='100,f1 " Save up to 100 marks, enable capital marks
set ignorecase " Ignore case when searching...
set smartcase " ...unless we type a capital

View File

@@ -0,0 +1,3 @@
" w!! to write a file as sudo
" stolen from Steve Losh
cmap w!! w !sudo tee % >/dev/null

View File

@@ -0,0 +1,15 @@
" via: http://rails-bestpractices.com/posts/60-remove-trailing-whitespace
" Strip trailing whitespace
function! <SID>StripTrailingWhitespaces()
" Preparation: save last search, and cursor position.
let _s=@/
let l = line(".")
let c = col(".")
" Do the business:
%s/\s\+$//e
" Clean up: restore previous search history, and cursor position
let @/=_s
call cursor(l, c)
endfunction
command! StripTrailingWhitespaces call <SID>StripTrailingWhitespaces()
nmap ,w :StripTrailingWhitespaces<CR>

View File

@@ -0,0 +1,20 @@
" Use Q to intelligently close a window
" (if there are multiple windows into the same buffer)
" or kill the buffer entirely if it's the last window looking into that buffer
function! CloseWindowOrKillBuffer()
let number_of_windows_to_this_buffer = len(filter(range(1, winnr('$')), "winbufnr(v:val) == bufnr('%')"))
" We should never bdelete a nerd tree
if matchstr(expand("%"), 'NERD') == 'NERD'
wincmd c
return
endif
if number_of_windows_to_this_buffer > 1
wincmd c
else
bdelete
endif
endfunction
nnoremap <silent> Q :call CloseWindowOrKillBuffer()<CR>

View File

@@ -0,0 +1,20 @@
" http://vimcasts.org/episodes/soft-wrapping-text/
function! SetupWrapping()
set wrap linebreak nolist
set showbreak=
endfunction
" TODO: this should happen automatically for certain file types (e.g. markdown)
command! -nargs=* Wrap :call SetupWrapping()<CR>
vmap <D-j> gj
vmap <D-k> gk
vmap <D-$> g$
vmap <D-^> g^
vmap <D-0> g^
nmap <D-j> gj
nmap <D-k> gk
nmap <D-$> g$
nmap <D-^> g^
nmap <D-0> g^

View File

@@ -0,0 +1,3 @@
let g:yankring_history_file = '.yankring-history'
nnoremap ,yr :YRShow<CR>
nnoremap C-y :YRShow<CR>