christoomey / vim-tmux-runner

Vim and tmux, sittin' in a tree...
MIT License
291 stars 37 forks source link

Stripping whitespace #18

Closed toomey8 closed 10 years ago

toomey8 commented 10 years ago

Plugin strips whitespace. Can we have an option for not doing so for Python?

toomey8 commented 10 years ago

Also handle blank lines in visual mode?

christoomey commented 10 years ago

Hey @toomey8,

I just pushed up a branch with the fixes needed to support python and other languages with syntactic whitespace: https://github.com/christoomey/vim-tmux-runner/tree/cjt-python-fixes

Can you try it out? Use the following steps:

$ cd ~/.vim/bundles/vim-tmux-runner
$ git status # => check for local changes
$ git stash save # => store away the changes
$ git fetch origin
$ git checkout cjt-python-fixes

After that, add the configuration list in the Python section of the Readme to your vimrc, and then you should be set to test interaction with a python REPL via VTR.

christoomey commented 10 years ago

@toomey8 I've pushed an update to the readme to fix the issue with the configuration settings. Can you test again to confirm all works?

As for the extra lines in the REPL, you might want to try switching off the AppendNewLine functionality by setting:

let g:VtrAppendNewline = 0

and comment back with your findings?

toomey8 commented 10 years ago

With:

let g:VtrAppendNewline = 0

it hangs if I run just the loop, i.e.

if x == 10:

print ("test")

works if I run with an extra line it works

toomey8 commented 10 years ago

Note also that if I have a function with a line in it before the end it is failing, i.e.

works

ret_column = []
for element in input_column:
    try:
        ret_column.append(func(element))
    except:
        ret_column.append(None)
return ret_column

fails

ret_column = []
for element in input_column:
    try:
        ret_column.append(func(element))
    except:
        ret_column.append(None)
return ret_column
toomey8 commented 10 years ago

Also, the below works in base OXS Python REPL but not Ipython for reasons I don't understand.

Not sure if this is TMR, Ipython or both, but thought I would document.

On Ipython it hangs on 'except' indentation

def silent_map(func, input_column): ret_column = [] for element in input_column: try: ret_column.append(func(element)) except: ret_column.append(None) return ret_column

toomey8 commented 10 years ago

OK, debugged this some:

If using this with ipython on OSX make sure you have the correct version of readlines

http://stackoverflow.com/questions/726449/installing-ipython-with-readline-on-the-mac

and then start iPython with 'ipython --no-autoindent'

this works like a trooper.

thanks, Chris, for your help on this! You are the best. I think you can close this issue with a note to include an extra line at the end of a function in ipython.

toomey8 commented 7 years ago

FYI I had trouble on a new installation of the Anaconda distribution getting this to work, but switched to a new strategy where I 'vip' to get the paragraph, write the chunk to a temporary file, and then source that with the below.

    silent! normal :VtrSendCommand execfile('f.py')

This has the benefits of not cluttering the REPL and bypassing any readline problems with Anaconda ipython.