dense-analysis / ale

Check syntax in Vim/Neovim asynchronously and fix files, with Language Server Protocol (LSP) support
BSD 2-Clause "Simplified" License
13.56k stars 1.44k forks source link

Completely custom command for javac? #3355

Open LandonSchropp opened 4 years ago

LandonSchropp commented 4 years ago

I'm working on a project with a specialized Java environment that lives within a VM. I've set up SSH with port forwarding, and I can easily run commands from the parent OS like this:

ssh -p 2222 landon@localhost <command>

Is it possible to override the javac command to use SSH? Something link this?

ssh -p 2222 landon@localhost javac -Xlink -classpath <classpath> <file>

Is it possible to override the classpath command? My project is using Gradle for its build system, but the modules are only located in a couple of places, and running Gradle is adding a few seconds of overhead for this project.

Thanks!

LandonSchropp commented 4 years ago

I've managed to make progress on this by writing a small script that handles the class path for me and defining my own linter:


" Define a custom Ale linter that does the following:
"
" * Runs the command via SSH.
" * Runs the bin/assemble script.
" * Only builds the current file, not the whole project.
" * Doesn't run Gradle (because it's too slow).
call ale#linter#Define('java', {
\   'name': 'javac_ssh',
\   'executable': { -> 'ssh' },
\   'command': 'ssh -p 2222 landon@localhost bin/assemble %s',
\   'output_stream': 'stderr',
\   'callback': 'ale_linters#java#javac#Handle',
\})

" Specify the linters we want to run for Java.
let g:ale_linters = {
\   'java': [ 'javac_ssh' ],
\}

" *Only* run the specified linters, not all of them.
let g:ale_linters_explicit = 1

This calls my command successful, and even parses the output. However, Ale doesn't want to actually display the results in my editor.