rhysd / reply.vim

REPLs play nicely with :terminal on Vim and Neovim
MIT License
186 stars 7 forks source link

ReplSend sending with extra line space causing errors #13

Open henryoliver opened 4 years ago

henryoliver commented 4 years ago

Hi there, thanks for this plugin!

Is there a way to remove extra line when sending the code to the REPL?

For example:

mysum = 0

for i in range(5, 11, 2):
    mysum += i

    if mysum == 5:
        break

print(mysum)

IndentationError: unexpected indent

This will throw an error due to the extra line space.

Thank you! Henry

rhysd commented 4 years ago

It is because empty line is used to notify Python REPL where indented block finishes.

mysum = 0

for i in range(5, 11, 2):
    mysum += i
    if mysum == 5:
        break

print(mysum)

would work.

It is not easy to fix this kind of behavior to work because, for example, simply removing all empty lines like below also doesn't work.

mysum = 0
for i in range(5, 11, 2):
    mysum += i
    if mysum == 5:
        break
print(mysum)

It is related to Python's syntax (indentation-oriented blocks) and its REPL's behavior.

henryoliver commented 4 years ago

Thanks for answer @rhysd !

Last question, can the ReplAuto watch for file changes and re-run the entire file?

Example:

watchmedo shell-command \
    --patterns="*.py" \
    --recursive \
    --command='python "${watch_src_path}"' \
    .

Thanks!