Skip to content

Commit

Permalink
Rewritten in pure vimscript
Browse files Browse the repository at this point in the history
Removes the ruby dependency on vim
  • Loading branch information
jeff committed Feb 21, 2014
1 parent a54aabc commit 66e32b9
Showing 1 changed file with 21 additions and 46 deletions.
67 changes: 21 additions & 46 deletions plugin/python.vim
Original file line number Diff line number Diff line change
Expand Up @@ -3,57 +3,32 @@ if exists("g:loaded_vimux_nose_test") || &cp
endif
let g:loaded_vimux_nose_test = 1

if !has("ruby")
finish
end

command RunAllNoseTests :call s:RunAllNoseTests()
command RunFocusedNoseTests :call s:RunFocusedNoseTests()
command RunCurrentNoseTests :call s:RunCurrentNoseTests()

function! FindVirtualEnv()
if $VIRTUAL_ENV != ''
return $VIRTUAL_ENV . "/bin/"
else
return ""
end
endfunction

function s:RunAllNoseTests()
ruby NoseTest.new.run_all
let virtualenv = FindVirtualEnv()
call VimuxRunCommand("clear && " . virtualenv . "nosetests *.py")
endfunction

function s:RunFocusedNoseTests()
ruby NoseTest.new.run_focused
function s:RunCurrentNoseTests()
let virtualenv = FindVirtualEnv()
let file_name = @%
call VimuxRunCommand("clear && " . virtualenv . "nosetests " . file_name)
endfunction

ruby << EOF
module VIM
class Buffer
def method_missing(method, *args, &block)
VIM.command "#{method} #{self.name}"
end
end
end

class NoseTest
def current_file
VIM::Buffer.current.name
end

def line_number
VIM::Buffer.current.line_number
end

def virtualenv
if Vim.evaluate('exists("g:NoseVirtualenv")') != 0
". #{Vim.evaluate('g:NoseVirtualenv')} && "
else
""
end
end

def run_all
send_to_vimux("#{virtualenv} nosetests '#{current_file}'")
end

def run_focused
send_to_vimux("#{virtualenv} noseline '#{current_file}' --line #{line_number}")
end

def send_to_vimux(test_command)
Vim.command("call VimuxRunCommand(\"clear && #{test_command}\")")
end
end
EOF
function s:RunFocusedNoseTests()
let virtualenv = FindVirtualEnv()
let line_number = getline('.')
let file_name = @%
call VimuxRunCommand("clear && " . virtualenv . "nosetests " . file_name . " --line " . line_number)
endfunction

0 comments on commit 66e32b9

Please sign in to comment.