Last active
December 11, 2015 03:58
-
-
Save rroblak/4541329 to your computer and use it in GitHub Desktop.
my .vimrc and plugins
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
set shell=/bin/sh | |
set nocompatible | |
" Vundle beginning | |
filetype off | |
set rtp+=~/.vim/bundle/Vundle.vim | |
call vundle#begin() | |
Plugin 'gmarik/vundle' | |
Plugin 'scrooloose/nerdtree' | |
Plugin 'tomtom/tlib_vim' | |
Plugin 'MarcWeber/vim-addon-mw-utils' | |
Plugin 'garbas/vim-snipmate' | |
Plugin 'L9' | |
Plugin 'FuzzyFinder' | |
call vundle#end() | |
filetype plugin indent on | |
" Vundle end | |
syntax on | |
set number | |
set foldmethod=syntax | |
set foldlevel=99 | |
set tags=.tags | |
set tabstop=2 | |
set shiftwidth=2 | |
set softtabstop=2 | |
set smarttab | |
set expandtab | |
autocmd FileType ruby,eruby,yaml,coffee,objc,scss,javascript autocmd BufWritePre <buffer> :%s/\s\+$//e | |
autocmd VimResized * wincmd = | |
map <F1> :NERDTreeToggle<CR> | |
map <F2> :NERDTree $GEM_HOME/gems<CR> | |
map <F3> :FufFile ./**/<CR> | |
map <F4> :FufRenewCache<CR> | |
map <F5> :OpenSpec<CR> | |
map <F7> :tabprevious<CR> | |
map <F8> :tabnext<CR> | |
map <F10> :set invnumber<CR> | |
map <F11> :s/['"]/\="'\""[submatch(0)!='"']/g<CR> | |
set pastetoggle=<F12> | |
map <C-C> :split<CR> | |
map <C-K> :tabedit %<CR> | |
:nnoremap <silent><Leader><C-]> <C-w><C-]><C-w>T |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
if exists("g:loaded_rodspec") | |
finish | |
endif | |
if !has("ruby") | |
echohl ErrorMsg | |
echon "Sorry, Rodspec requires ruby support." | |
finish | |
endif | |
let g:loaded_rodspec = "true" | |
function! OpenSpec() | |
:ruby open_spec | |
endfunction | |
function! RunSpec() | |
:ruby run_spec | |
redraw! | |
endfunction | |
command OpenSpec :call OpenSpec() | |
command RunSpec :call RunSpec() | |
:ruby << EOF | |
def open_spec | |
return if VIM::Buffer.current.name.nil? | |
relative_file_path_array = VIM::Buffer.current.name.sub(Dir.pwd, '').split(File::SEPARATOR)[1..-1] | |
file_path_array = [Dir.pwd] | |
if relative_file_path_array[0] == 'spec' | |
file_path_array << 'app' | |
file_path_array << relative_file_path_array[1..-2] | |
file_path_array << File.basename(VIM::Buffer.current.name, '_spec.rb') + '.rb' | |
else | |
file_path_array << 'spec' | |
array_index_start = relative_file_path_array[0] == 'app' ? 1 : 0 | |
file_path_array << relative_file_path_array[array_index_start..-2] | |
file_path_array << File.basename(VIM::Buffer.current.name, '.rb') + '_spec.rb' | |
end | |
VIM.command("split #{File.join(file_path_array)}") | |
end | |
def run_spec | |
apple_script = <<-HEREDOC | |
tell application "Terminal" | |
set i to 0 | |
set nextTabIndex to -1 | |
repeat with curTab in tabs of window 1 | |
if selected of curTab then | |
set nextTabIndex to i + 1 | |
else if i is equal to nextTabIndex then | |
if processes of curTab is equal to {"login", "bash"} then | |
do script "zeus rspec #{VIM::Buffer.current.name} -f d" in curTab | |
exit repeat | |
end if | |
end if | |
set i to i + 1 | |
end repeat | |
end tell | |
HEREDOC | |
statements = apple_script.split("\n").map {|line| line.strip} | |
system("osascript #{statements.map{|s| "-e '#{s}'"}.join(' ')}") | |
end | |
EOF |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
if exists("g:loaded_ruby_doc") | |
finish | |
endif | |
if !has("ruby") | |
echohl ErrorMsg | |
echon "Sorry, RubyDoc requires ruby support." | |
finish | |
endif | |
let g:loaded_ruby_doc = "true" | |
function! OpenRubyDoc(constant) | |
:ruby open_ruby_doc | |
endfunction | |
command -nargs=1 OpenRubyDoc :call OpenRubyDoc(<f-args>) | |
:ruby << EOF | |
def open_ruby_doc | |
system("open", "http://www.ruby-doc.org/core-1.9.3/#{VIM.evaluate("a:constant").capitalize}.html") | |
end | |
EOF |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment