Added Ctrl-s
to open spec for any file you're looking at
Similar to rails.vim's :A and :AV command, except it knows about fast_spec. Could be expanded in the future to add more spec paths.
This commit is contained in:
parent
b1dfcb1901
commit
86c5fe1ea6
@ -296,6 +296,7 @@ files contain key mappings as well (TODO: probably will move them out to skwp-ke
|
||||
* `,qa/` - quickfix Ack last search (Steve Losh)
|
||||
* `,qg/` - quickfix GitGrep last search
|
||||
* `,T` - Tag list (list of methods in a class)
|
||||
* `Ctrl-s` - Open related spec in a split. Similar to :A and :AV from rails.vim but is also aware of the fast_spec dir and faster to type
|
||||
|
||||
#### File Navigation
|
||||
|
||||
@ -356,6 +357,7 @@ files contain key mappings as well (TODO: probably will move them out to skwp-ke
|
||||
* `,cf` - Copy Filename of current file (full path) into system (not vi) paste buffer
|
||||
* `,cn` - Copy Filename of current file (name only, no path)
|
||||
* `,vc` - (Vim Command) copies the command under your cursor and executes it in vim. Great for testing single line changes to vimrc.
|
||||
* `,vr` - (Vim Reload) source current file as a vim file
|
||||
* `,yw` - yank a word from anywhere within the word (so you don't have to go to the beginning of it)
|
||||
* `,ow` - overwrite a word with whatever is in your yank buffer - you can be anywhere on the word. saves having to visually select it
|
||||
* `,w` - strip trailing whitespaces
|
||||
|
@ -14,6 +14,7 @@ hi! link rubyPseudoVariable Type
|
||||
hi! link rubyRailsARAssociationMethod Title
|
||||
hi! link rubyRailsARValidationMethod Title
|
||||
hi! link rubyRailsMethod Title
|
||||
hi! link MatchParen DiffText
|
||||
|
||||
" Enforce the colors set here
|
||||
au VimEnter * so ~/.vim/plugin/settings/solarized.vim
|
||||
|
@ -163,12 +163,12 @@ nnoremap <silent> ,cn :let @* = expand("%:t")<CR>
|
||||
"Clear current search highlight by double tapping //
|
||||
nmap <silent> // :nohlsearch<CR>
|
||||
|
||||
" (c)opy (c)ommand - which allows us to execute
|
||||
" the line we're looking at (it does so by yy-copy, colon
|
||||
" to get to the command mode, C-f to get to history editing
|
||||
" p to paste it, C-c to return to command mode, and CR to execute
|
||||
"(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>
|
||||
|
||||
|
32
vim/plugin/settings/yadr-spec-opener.vim
Normal file
32
vim/plugin/settings/yadr-spec-opener.vim
Normal file
@ -0,0 +1,32 @@
|
||||
" Find the related spec for any file you open. Requires
|
||||
" * Your specs live in spec/ or fast_spec/
|
||||
" * Your pwd (current dir) is the project root
|
||||
" * You use the same dir structure in your code and specs so that
|
||||
" code living at lib/foo/bar.rb has a spec at spec/lib/foo/bar.rb
|
||||
"
|
||||
" This method handles files in fast_spec unlike the :A and :AV functions
|
||||
" that ship with rails.vim
|
||||
function! FindSpec()
|
||||
let s:fullpath = expand("%:p")
|
||||
let s:filepath = expand("%:h")
|
||||
let s:fname = expand("%:t")
|
||||
|
||||
" Possible names for the spec/test for the file we're looking at
|
||||
let s:test_names = [substitute(s:fname, ".rb$", "_spec.rb", ""), substitute(s:fname, ".rb$", "_test.rb", "")]
|
||||
|
||||
" Possible paths
|
||||
let s:test_paths = ["spec", "fast_spec", "test"]
|
||||
for test_name in s:test_names
|
||||
for path in s:test_paths
|
||||
let s:filepath_without_app = substitute(s:filepath, "app/", "", "")
|
||||
let s:spec_path = path . "/" . s:filepath_without_app . "/" . test_name
|
||||
let s:full_spec_path = substitute(s:fullpath, s:filepath . "/" . s:fname, s:spec_path, "")
|
||||
if filereadable(s:full_spec_path)
|
||||
execute ":botright vsp " . s:full_spec_path
|
||||
return
|
||||
endif
|
||||
endfor
|
||||
endfor
|
||||
endfunction
|
||||
|
||||
nnoremap <C-s> :call FindSpec()<CR>
|
Loading…
Reference in New Issue
Block a user