donkirkby / live-py-plugin

Live coding in Python with PyCharm, Emacs, Sublime Text, or even a browser
https://donkirkby.github.io/live-py-plugin
MIT License
292 stars 56 forks source link

Vim support #287

Open blayz3r opened 3 years ago

blayz3r commented 3 years ago

Any plans to support Vim

donkirkby commented 3 years ago

I've never been a regular user of Vim, so I don't plan to add support for it. If you or anyone else is interested in contributing support for Vim, there's a description of the process in the contributing file. It mostly involves launching a Python subprocess to call the tracer code, and then displaying the results in a side-by-side window.

I did a little searching for how to write a Vim plugin, and it looks like there's lots of documentation. One example is Learn Vimscript the Hard Way.

blayz3r commented 3 years ago

So currently there is a plugin here that does something similar: https://github.com/metakirby5/codi.vim Basically is does this by:

The difference ofcourse is that codi gets ouput put from the Repl and live-py-plugin does some extra manupualtion.

Is it possible to run the plugin as a script e.g run python live-py-plugin.py > output.txt

image

donkirkby commented 3 years ago

Thanks for doing the research. Yes, the core analysis is done by a Python package called space_tracer, and you can run that as a command-line tool. See the contributing file for some hints, look at Space Tracer's getting started page, or look at its parse_args() method in the source code.

Let me know if you need any hints on how to make Space Tracer do what you need.

OsKaR31415 commented 2 years ago

Simple solution :

  1. make a shell script that runs space_tracer
  2. run that shell script in a vim terminal buffer

Here is my script (in zsh) (named space_tracer_loop):

#!/bin/zsh

fswatch -0 $1 | while read -d "" event
do
    clear
    space_tracer $1
done

It uses fswatch.

Here is the command to run it in a vim split terminal : :vert term space_tracer_loop %

And, each time you save your file, it will update ! It is not exactly live, since you have to save the file, but this is a very simple solution that basically does the job. I guess it is possible to use the contents of the vim buffer instead, but that would require far more work, and the usage of vimscript (or lua, or python, or any language to configure vim, because vimscript is not the only language you can use to configure vim).