Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Vim support #287

Open
blayz3r opened this issue Oct 6, 2020 · 4 comments
Open

Vim support #287

blayz3r opened this issue Oct 6, 2020 · 4 comments

Comments

@blayz3r
Copy link

blayz3r commented Oct 6, 2020

Any plans to support Vim

@donkirkby
Copy link
Owner

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
Copy link
Author

blayz3r commented Oct 13, 2020

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

  • Start a job that invokes script on the bin, which is python in this case
  • If asynchronous, grab stdout until the number of prompts received from stdout matches the number of lines in the main buffer; if synchronous, just run the job to conclusion and grab the output
  • Get the values associated with each line using the algorithm described here
  • Replace the Codi buffer contents

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
Copy link
Owner

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
Copy link

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).

@donkirkby donkirkby added this to the Far future milestone Mar 23, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants