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

Running against a not yet saved file #23

Open
marlun opened this issue Apr 9, 2015 · 1 comment
Open

Running against a not yet saved file #23

marlun opened this issue Apr 9, 2015 · 1 comment

Comments

@marlun
Copy link

marlun commented Apr 9, 2015

Would it be possible to somehow use this to asynchronously get information about errors in a file before saving it? Maybe running the check when leaving insert mode or some smarter autocmd event?

@pgdouyon
Copy link
Owner

pgdouyon commented Apr 9, 2015

I don't think this could be done easily. You would either need a compiler/linter that supports piping output directly into it (as opposed to passing a file) or would need to save the file to a temp file.

But saving to a temp file could make it difficult for the compiler/linter to properly resolve dependencies if it looks for dependencies in the same project directory as the file being checked. Since a temp file would be stored in some random location the dependencies would have to be explicitly specified.

Assuming that dependencies are not a problem, or a mechanism is already in place to handle them (like setting the Java classpath) it could probably be most easily done via a compiler plugin

let tempfile = tempname()
call writefile(getline(1,"$"), tempfile)

" determine dependencies

CompilerSet makeprg=some_prg\ --file\ tempfile\ <dependencies>

The drawbacks of doing it from a compiler plugin being

  • The tempfile isn't automatically deleted after each run. Although you can get around this by setting a variable to hold the tempfile name so that you can reuse the tempfile every time :compiler is called (which happens everytime Accio is run).
    • Similar to how the javac example in the readme stores the classpath.
  • Accio's current design would cause it to assume that this compiler is run on a group of files instead of a single file (kind of like a project-wide build script). Which means that Accio could only store the results from one run of this compiler at a time, as opposed to storing the results from one run for each buffer. The main consequence being that if you ran this compiler on two separate buffers, the signs from the first run (and the first buffer) would disappear when the second run is started.
    • I could try and modify the API to allow some way of forcing an Accio command to be local to a buffer, instead of Accio trying to figure it out on its own.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants