update vim and git config
This commit is contained in:
parent
a402bb69f4
commit
eeee46d29f
97
.vimrc
Normal file
97
.vimrc
Normal file
|
@ -0,0 +1,97 @@
|
||||||
|
filetype indent on
|
||||||
|
set tabstop=4
|
||||||
|
set smarttab
|
||||||
|
set shiftwidth=4
|
||||||
|
set autoindent
|
||||||
|
set expandtab
|
||||||
|
syntax on
|
||||||
|
set number
|
||||||
|
set wildmenu
|
||||||
|
set mouse=a
|
||||||
|
|
||||||
|
" The PC is fast enough, do syntax highlight syncing from start
|
||||||
|
autocmd BufEnter * :syntax sync fromstart
|
||||||
|
|
||||||
|
" Enable filetype plugins and indention
|
||||||
|
filetype on
|
||||||
|
filetype plugin on
|
||||||
|
|
||||||
|
" prefer unix over windows over os9 formats
|
||||||
|
set fileformats=unix,dos,mac
|
||||||
|
|
||||||
|
" utf-8 default encoding
|
||||||
|
set enc=utf-8
|
||||||
|
|
||||||
|
" keep some more lines for scope
|
||||||
|
set scrolloff=5
|
||||||
|
|
||||||
|
" ; is an alias for :
|
||||||
|
nnoremap ; :
|
||||||
|
|
||||||
|
" template language support (SGML / XML too)
|
||||||
|
" ------------------------------------------
|
||||||
|
" and disable taht stupid html rendering (like making stuff bold etc)
|
||||||
|
|
||||||
|
fun! s:SelectHTML()
|
||||||
|
let n = 1
|
||||||
|
while n < 50 && n < line("$")
|
||||||
|
" check for jinja
|
||||||
|
if getline(n) =~ '{%\s*\(extends\|block\|macro\|set\|if\|for\|include\|trans\)\>'
|
||||||
|
set ft=htmljinja
|
||||||
|
return
|
||||||
|
endif
|
||||||
|
" check for django
|
||||||
|
if getline(n) =~ '{%\s*\(extends\|block\|comment\|ssi\|if\|for\|blocktrans\)\>'
|
||||||
|
set ft=htmldjango
|
||||||
|
return
|
||||||
|
endif
|
||||||
|
" check for mako
|
||||||
|
if getline(n) =~ '<%\(def\|inherit\)'
|
||||||
|
set ft=mako
|
||||||
|
return
|
||||||
|
endif
|
||||||
|
" check for genshi
|
||||||
|
if getline(n) =~ 'xmlns:py\|py:\(match\|for\|if\|def\|strip\|xmlns\)'
|
||||||
|
set ft=genshi
|
||||||
|
return
|
||||||
|
endif
|
||||||
|
let n = n + 1
|
||||||
|
endwhile
|
||||||
|
" go with html
|
||||||
|
set ft=html
|
||||||
|
endfun
|
||||||
|
|
||||||
|
autocmd BufNewFile,BufRead *.html,*.htm call s:SelectHTML()
|
||||||
|
|
||||||
|
" CSS
|
||||||
|
" ---
|
||||||
|
autocmd FileType css setlocal expandtab shiftwidth=4 tabstop=4 softtabstop=4
|
||||||
|
|
||||||
|
" Javascript
|
||||||
|
" ----------
|
||||||
|
autocmd FileType javascript setlocal expandtab shiftwidth=2 tabstop=2 softtabstop=2 colorcolumn=79
|
||||||
|
let javascript_enable_domhtmlcss=1
|
||||||
|
|
||||||
|
|
||||||
|
" New Config
|
||||||
|
" ----------------------------------------------------------------
|
||||||
|
|
||||||
|
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
|
||||||
|
" CUSTOM AUTOCMDS
|
||||||
|
" """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
|
||||||
|
augroup vimrcEx
|
||||||
|
" Clear all autocmds in the group
|
||||||
|
autocmd!
|
||||||
|
autocmd FileType text setlocal textwidth=78
|
||||||
|
" Jump to last cursor position unless it's invalid or in an event handler
|
||||||
|
autocmd BufReadPost *
|
||||||
|
\ if line("'\"") > 0 && line("'\"") <= line("$") |
|
||||||
|
\ exe "normal g`\"" |
|
||||||
|
\ endif
|
||||||
|
|
||||||
|
autocmd FileType ruby,haml,eruby,yaml,html,javascript,sass,cucumber set ai sw=2 sts=2 et
|
||||||
|
autocmd FileType python set sw=4 sts=4 et
|
||||||
|
|
||||||
|
" Indent p tags
|
||||||
|
autocmd FileType html,eruby if g:html_indent_tags !~ '\\|p\>' | let g:html_indent_tags .= '\|p\|li\|dt\|dd' | endif
|
||||||
|
augroup END
|
35
gitconfig
Normal file
35
gitconfig
Normal file
|
@ -0,0 +1,35 @@
|
||||||
|
[user]
|
||||||
|
name = Michael Campagnaro
|
||||||
|
email = mikecampo@gmail.com
|
||||||
|
[diff]
|
||||||
|
[color]
|
||||||
|
ui = auto
|
||||||
|
[alias]
|
||||||
|
st = status
|
||||||
|
ci = commit
|
||||||
|
co = checkout
|
||||||
|
di = diff
|
||||||
|
dc = diff --cached
|
||||||
|
amend = commit --amend
|
||||||
|
aa = add --all
|
||||||
|
head = !git l -1
|
||||||
|
h = !git head
|
||||||
|
hp = "!source ~/.githelpers && show_git_head"
|
||||||
|
r = !git l -20
|
||||||
|
ra = !git r --all
|
||||||
|
ff = merge --ff-only
|
||||||
|
pullff = pull --ff-only
|
||||||
|
noff = merge --no-ff
|
||||||
|
l = "!source ~/.githelpers && pretty_git_log"
|
||||||
|
la = !git l --all
|
||||||
|
div = divergence
|
||||||
|
gn = goodness
|
||||||
|
gnc = goodness --cached
|
||||||
|
fa = fetch --all
|
||||||
|
pom = push origin master
|
||||||
|
b = branch
|
||||||
|
ds = diff --stat=160,120
|
||||||
|
dh1 = diff HEAD~1
|
||||||
|
|
||||||
|
[merge]
|
||||||
|
tool = vimdiff
|
40
githelpers
Normal file
40
githelpers
Normal file
|
@ -0,0 +1,40 @@
|
||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
# Log output:
|
||||||
|
#
|
||||||
|
# * 51c333e (12 days) <Gary Bernhardt> add vim-eunuch
|
||||||
|
#
|
||||||
|
# The time massaging regexes start with ^[^<]* because that ensures that they
|
||||||
|
# only operate before the first "<". That "<" will be the beginning of the
|
||||||
|
# author name, ensuring that we don't destroy anything in the commit message
|
||||||
|
# that looks like time.
|
||||||
|
#
|
||||||
|
# The log format uses } characters between each field, and `column` is later
|
||||||
|
# used to split on them. A } in the commit subject or any other field will
|
||||||
|
# break this.
|
||||||
|
|
||||||
|
HASH="%C(yellow)%h%Creset"
|
||||||
|
RELATIVE_TIME="%Cgreen(%ar)%Creset"
|
||||||
|
AUTHOR="%C(bold blue)<%an>%Creset"
|
||||||
|
REFS="%C(red)%d%Creset"
|
||||||
|
SUBJECT="%s"
|
||||||
|
|
||||||
|
FORMAT="$HASH}$RELATIVE_TIME}$AUTHOR}$REFS $SUBJECT"
|
||||||
|
|
||||||
|
show_git_head() {
|
||||||
|
pretty_git_log -1
|
||||||
|
git show -p --pretty="tformat:"
|
||||||
|
}
|
||||||
|
|
||||||
|
pretty_git_log() {
|
||||||
|
git log --graph --abbrev-commit --date=relative --pretty="tformat:${FORMAT}" $* |
|
||||||
|
# Repalce (2 years ago) with (2 years)
|
||||||
|
sed -Ee 's/(^[^<]*) ago)/\1)/' |
|
||||||
|
# Replace (2 years, 5 months) with (2 years)
|
||||||
|
sed -Ee 's/(^[^<]*), [[:digit:]]+ .*months?)/\1)/' |
|
||||||
|
# Line columns up based on } delimiter
|
||||||
|
column -s '}' -t |
|
||||||
|
# Page only if we need to
|
||||||
|
less -FXRS
|
||||||
|
}
|
||||||
|
|
302
vimrc
302
vimrc
|
@ -1,82 +1,256 @@
|
||||||
filetype indent on
|
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
|
||||||
set tabstop=4
|
" BASIC EDITING CONFIGURATION
|
||||||
set smarttab
|
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
|
||||||
set shiftwidth=4
|
set nocompatible
|
||||||
set autoindent
|
" allow unsaved background buffers and remember marks/undo for them
|
||||||
|
set hidden
|
||||||
|
" remember more commands and search history
|
||||||
|
set history=10000
|
||||||
set expandtab
|
set expandtab
|
||||||
|
set tabstop=4
|
||||||
|
set shiftwidth=4
|
||||||
|
set softtabstop=4
|
||||||
|
set autoindent
|
||||||
|
set laststatus=2
|
||||||
|
set showmatch
|
||||||
|
set incsearch
|
||||||
|
set hlsearch
|
||||||
|
" make searches case-sensitive only if they contain upper-case characters
|
||||||
|
set ignorecase smartcase
|
||||||
|
" highlight current line
|
||||||
|
set cmdheight=2
|
||||||
|
set switchbuf=useopen
|
||||||
|
set numberwidth=5
|
||||||
|
set showtabline=2
|
||||||
|
set winwidth=79
|
||||||
|
set shell=bash
|
||||||
|
" Prevent Vim from clobbering the scrollback buffer. See
|
||||||
|
" http://www.shallowsky.com/linux/noaltscreen.html
|
||||||
|
set t_ti= t_te=
|
||||||
|
" keep more context when scrolling off the end of a buffer
|
||||||
|
set scrolloff=3
|
||||||
|
" Store temporary files in a central spot
|
||||||
|
set backup
|
||||||
|
set backupdir=~/.vim-tmp,~/.tmp,~/tmp,/var/tmp,/tmp
|
||||||
|
set directory=~/.vim-tmp,~/.tmp,~/tmp,/var/tmp,/tmp
|
||||||
|
" allow backspacing over everything in insert mode
|
||||||
|
set backspace=indent,eol,start
|
||||||
|
" display incomplete commands
|
||||||
|
set showcmd
|
||||||
|
" Enable highlighting for syntax
|
||||||
syntax on
|
syntax on
|
||||||
set number
|
" Enable file type detection.
|
||||||
|
" Use the default filetype settings, so that mail gets 'tw' set to 72,
|
||||||
|
" 'cindent' is on in C files, etc.
|
||||||
|
" Also load indent files, to automatically do language-dependent indenting.
|
||||||
|
filetype plugin indent on
|
||||||
|
" use emacs-style tab completion when selecting files, etc
|
||||||
|
set wildmode=longest,list
|
||||||
|
" make tab completion for files/buffers act like bash
|
||||||
set wildmenu
|
set wildmenu
|
||||||
set mouse=a
|
let mapleader=","
|
||||||
|
|
||||||
" The PC is fast enough, do syntax highlight syncing from start
|
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
|
||||||
autocmd BufEnter * :syntax sync fromstart
|
" CUSTOM AUTOCMDS
|
||||||
|
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
|
||||||
|
augroup vimrcEx
|
||||||
|
" Clear all autocmds in the group
|
||||||
|
autocmd!
|
||||||
|
autocmd FileType text setlocal textwidth=78
|
||||||
|
" Jump to last cursor position unless it's invalid or in an event handler
|
||||||
|
autocmd BufReadPost * if line("'\"") > 1 && line("'\"") <= line("$") | exe "normal! g`\"" | endif
|
||||||
|
|
||||||
" Remember cursor position
|
autocmd FileType ruby,haml,eruby,yaml,html,javascript,sass,cucumber set ai sw=2 sts=2 et
|
||||||
au BufReadPost * if line("'\"") > 1 && line("'\"") <= line("$") | exe "normal! g`\"" | endif
|
autocmd FileType python set sw=4 sts=4 et
|
||||||
|
|
||||||
" Enable filetype plugins and indention
|
" Indent p tags
|
||||||
filetype on
|
autocmd FileType html,eruby if g:html_indent_tags !~ '\\|p\>' | let g:html_indent_tags .= '\|p\|li\|dt\|dd' | endif
|
||||||
filetype plugin on
|
augroup END
|
||||||
|
|
||||||
" prefer unix over windows over os9 formats
|
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
|
||||||
set fileformats=unix,dos,mac
|
" MISC KEY MAPS
|
||||||
|
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
|
||||||
|
let mapleader=","
|
||||||
|
|
||||||
" utf-8 default encoding
|
" insert a hash rocket with <c-l>
|
||||||
set enc=utf-8
|
imap <c-l> <space>=><space>
|
||||||
|
|
||||||
" keep some more lines for scope
|
" set esc to <c-c>
|
||||||
set scrolloff=5
|
imap <c-c> <esc>
|
||||||
|
|
||||||
" ; is an alias for :
|
" Clear the search buffer (highlighting) when hitting return
|
||||||
nnoremap ; :
|
:nnoremap <CR> :nohlsearch<cr>
|
||||||
|
nnoremap <leader><leader> <c-^>
|
||||||
|
|
||||||
" template language support (SGML / XML too)
|
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
|
||||||
" ------------------------------------------
|
" ARROW KEYS ARE UNACCEPTABLE
|
||||||
" and disable taht stupid html rendering (like making stuff bold etc)
|
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
|
||||||
|
map <Left> :echo "no!"<cr>
|
||||||
|
map <Right> :echo "no!"<cr>
|
||||||
|
map <Up> :echo "no!"<cr>
|
||||||
|
map <Down> :echo "no!"<cr>
|
||||||
|
|
||||||
fun! s:SelectHTML()
|
|
||||||
let n = 1
|
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
|
||||||
while n < 50 && n < line("$")
|
" MULTIPURPOSE TAB KEY
|
||||||
" check for jinja
|
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
|
||||||
if getline(n) =~ '{%\s*\(extends\|block\|macro\|set\|if\|for\|include\|trans\)\>'
|
function! InsertTabWrapper()
|
||||||
set ft=htmljinja
|
let col = col('.') - 1
|
||||||
return
|
if !col || getline('.')[col - 1] !~ '\k'
|
||||||
endif
|
return "\<tab>"
|
||||||
" check for django
|
else
|
||||||
if getline(n) =~ '{%\s*\(extends\|block\|comment\|ssi\|if\|for\|blocktrans\)\>'
|
return "\<c-p>"
|
||||||
set ft=htmldjango
|
|
||||||
return
|
|
||||||
endif
|
|
||||||
" check for mako
|
|
||||||
if getline(n) =~ '<%\(def\|inherit\)'
|
|
||||||
set ft=mako
|
|
||||||
return
|
|
||||||
endif
|
endif
|
||||||
" check for genshi
|
endfunction
|
||||||
if getline(n) =~ 'xmlns:py\|py:\(match\|for\|if\|def\|strip\|xmlns\)'
|
inoremap <tab> <c-r>=InsertTabWrapper()<cr>
|
||||||
set ft=genshi
|
inoremap <s-tab> <c-n>
|
||||||
return
|
|
||||||
|
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
|
||||||
|
" RENAME CURRENT FILE
|
||||||
|
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
|
||||||
|
function! RenameFile()
|
||||||
|
let old_name = expand('%')
|
||||||
|
let new_name = input('New file name: ', expand('%'), 'file')
|
||||||
|
if new_name != '' && new_name != old_name
|
||||||
|
exec ':saveas ' . new_name
|
||||||
|
exec ':silent !rm ' . old_name
|
||||||
|
redraw!
|
||||||
endif
|
endif
|
||||||
let n = n + 1
|
endfunction
|
||||||
endwhile
|
map <leader>n :call RenameFile()<cr>
|
||||||
" go with html
|
|
||||||
set ft=html
|
|
||||||
endfun
|
|
||||||
|
|
||||||
autocmd FileType html,xhtml,xml,htmldjango,htmljinja,eruby,mako setlocal expandtab shiftwidth=2 tabstop=2 softtabstop=2
|
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
|
||||||
autocmd BufNewFile,BufRead *.rhtml setlocal ft=eruby
|
" PROMOTE VARIABLE TO RSPEC LET
|
||||||
autocmd BufNewFile,BufRead *.mako setlocal ft=mako
|
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
|
||||||
autocmd BufNewFile,BufRead *.tmpl setlocal ft=htmljinja
|
function! PromoteToLet()
|
||||||
autocmd BufNewFile,BufRead *.py_tmpl setlocal ft=python
|
:normal! dd
|
||||||
autocmd BufNewFile,BufRead *.html,*.htm call s:SelectHTML()
|
" :exec '?^\s*it\>'
|
||||||
|
:normal! P
|
||||||
|
:.s/\(\w\+\) = \(.*\)$/let(:\1) { \2 }/
|
||||||
|
:normal ==
|
||||||
|
endfunction
|
||||||
|
:command! PromoteToLet :call PromoteToLet()
|
||||||
|
:map <leader>p :PromoteToLet<cr>
|
||||||
|
|
||||||
" CSS
|
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
|
||||||
" ---
|
" MAPS TO JUMP TO SPECIFIC COMMAND-T TARGETS AND FILES
|
||||||
autocmd FileType css setlocal expandtab shiftwidth=4 tabstop=4 softtabstop=4
|
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
|
||||||
|
map <leader>gr :topleft :split config/routes.rb<cr>
|
||||||
|
function! ShowRoutes()
|
||||||
|
" Requires 'scratch' plugin
|
||||||
|
:topleft 100 :split __Routes__
|
||||||
|
" Make sure Vim doesn't write __Routes__ as a file
|
||||||
|
:set buftype=nofile
|
||||||
|
" Delete everything
|
||||||
|
:normal 1GdG
|
||||||
|
" Put routes output in buffer
|
||||||
|
:0r! rake -s routes
|
||||||
|
" Size window to number of lines (1 plus rake output length)
|
||||||
|
:exec ":normal " . line("$") . _ "
|
||||||
|
" Move cursor to bottom
|
||||||
|
:normal 1GG
|
||||||
|
" Delete empty trailing line
|
||||||
|
:normal dd
|
||||||
|
endfunction
|
||||||
|
map <leader>gR :call ShowRoutes()<cr>
|
||||||
|
map <leader>gv :CommandTFlush<cr>\|:CommandT app/views<cr>
|
||||||
|
map <leader>gc :CommandTFlush<cr>\|:CommandT app/controllers<cr>
|
||||||
|
map <leader>gm :CommandTFlush<cr>\|:CommandT app/models<cr>
|
||||||
|
map <leader>gh :CommandTFlush<cr>\|:CommandT app/helpers<cr>
|
||||||
|
map <leader>gl :CommandTFlush<cr>\|:CommandT lib<cr>
|
||||||
|
map <leader>gp :CommandTFlush<cr>\|:CommandT public<cr>
|
||||||
|
map <leader>gs :CommandTFlush<cr>\|:CommandT public/stylesheets/sass<cr>
|
||||||
|
map <leader>gf :CommandTFlush<cr>\|:CommandT features<cr>
|
||||||
|
map <leader>gg :topleft 100 :split Gemfile<cr>
|
||||||
|
map <leader>gt :CommandTFlush<cr>\|:CommandTTag<cr>
|
||||||
|
map <leader>f :CommandTFlush<cr>\|:CommandT<cr>
|
||||||
|
map <leader>F :CommandTFlush<cr>\|:CommandT %%<cr>
|
||||||
|
|
||||||
" Javascript
|
|
||||||
" ----------
|
|
||||||
autocmd FileType javascript setlocal expandtab shiftwidth=2 tabstop=2 softtabstop=2 colorcolumn=79
|
|
||||||
let javascript_enable_domhtmlcss=1
|
|
||||||
|
|
||||||
|
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
|
||||||
|
" SWITCH BETWEEN TEST AND PRODUCTION CODE
|
||||||
|
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
|
||||||
|
function! OpenTestAlternate()
|
||||||
|
let new_file = AlternateForCurrentFile()
|
||||||
|
exec ':e ' . new_file
|
||||||
|
endfunction
|
||||||
|
function! AlternateForCurrentFile()
|
||||||
|
let current_file = expand("%")
|
||||||
|
let new_file = current_file
|
||||||
|
let in_spec = match(current_file, '^spec/') != -1
|
||||||
|
let going_to_spec = !in_spec
|
||||||
|
let in_app = match(current_file, '\<controllers\>') != -1 || match(current_file, '\<models\>') != -1 || match(current_file, '\<views\>') != -1
|
||||||
|
if going_to_spec
|
||||||
|
if in_app
|
||||||
|
let new_file = substitute(new_file, '^app/', '', '')
|
||||||
|
end
|
||||||
|
let new_file = substitute(new_file, '\.rb$', '_spec.rb', '')
|
||||||
|
let new_file = 'spec/' . new_file
|
||||||
|
else
|
||||||
|
let new_file = substitute(new_file, '_spec\.rb$', '.rb', '')
|
||||||
|
let new_file = substitute(new_file, '^spec/', '', '')
|
||||||
|
if in_app
|
||||||
|
let new_file = 'app/' . new_file
|
||||||
|
end
|
||||||
|
endif
|
||||||
|
return new_file
|
||||||
|
endfunction
|
||||||
|
nnoremap <leader>. :call OpenTestAlternate()<cr>
|
||||||
|
|
||||||
|
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
|
||||||
|
" RUNNING TESTS
|
||||||
|
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
|
||||||
|
function! RunTests(filename)
|
||||||
|
" Write the file and run tests for the given filename
|
||||||
|
:w
|
||||||
|
:silent !echo;echo;echo;echo;echo;echo;echo;echo;echo;echo
|
||||||
|
:silent !echo;echo;echo;echo;echo;echo;echo;echo;echo;echo
|
||||||
|
:silent !echo;echo;echo;echo;echo;echo;echo;echo;echo;echo
|
||||||
|
:silent !echo;echo;echo;echo;echo;echo;echo;echo;echo;echo
|
||||||
|
:silent !echo;echo;echo;echo;echo;echo;echo;echo;echo;echo
|
||||||
|
:silent !echo;echo;echo;echo;echo;echo;echo;echo;echo;echo
|
||||||
|
if match(a:filename, '\.feature$') != -1
|
||||||
|
exec ":!script/features " . a:filename
|
||||||
|
else
|
||||||
|
if filereadable("script/test")
|
||||||
|
exec ":!script/test " . a:filename
|
||||||
|
elseif filereadable("Gemfile")
|
||||||
|
exec ":!bundle exec rspec --color " . a:filename
|
||||||
|
else
|
||||||
|
exec ":!rspec --color " . a:filename
|
||||||
|
end
|
||||||
|
end
|
||||||
|
endfunction
|
||||||
|
|
||||||
|
function! SetTestFile()
|
||||||
|
" Set the spec file that tests will be run for.
|
||||||
|
let t:grb_test_file=@%
|
||||||
|
endfunction
|
||||||
|
|
||||||
|
function! RunTestFile(...)
|
||||||
|
if a:0
|
||||||
|
let command_suffix = a:1
|
||||||
|
else
|
||||||
|
let command_suffix = ""
|
||||||
|
endif
|
||||||
|
|
||||||
|
" Run the tests for the previously-marked file.
|
||||||
|
let in_test_file = match(expand("%"), '\(.feature\|_spec.rb\)$') != -1
|
||||||
|
if in_test_file
|
||||||
|
call SetTestFile()
|
||||||
|
elseif !exists("t:grb_test_file")
|
||||||
|
return
|
||||||
|
end
|
||||||
|
call RunTests(t:grb_test_file . command_suffix)
|
||||||
|
endfunction
|
||||||
|
|
||||||
|
function! RunNearestTest()
|
||||||
|
let spec_line_number = line('.')
|
||||||
|
call RunTestFile(":" . spec_line_number . " -b")
|
||||||
|
endfunction
|
||||||
|
|
||||||
|
map <leader>t :call RunTestFile()<cr>
|
||||||
|
map <leader>T :call RunNearestTest()<cr>
|
||||||
|
map <leader>a :call RunTests('')<cr>
|
||||||
|
map <leader>c :w\|:!script/features<cr>
|
||||||
|
map <leader>w :w\|:!script/features --profile wip<cr>
|
||||||
|
|
Loading…
Reference in New Issue
Block a user