You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In polyglot monorepos it is a royal pain that I cannot have plugins like coc-java correctly set the classpath for the java language server since there is not a pom.xml or a gradle.build at the root of the project.
My team uses Bazel and there are a number of us that strictly use vim since there is so much context switching between languages. If possible, it would be fantastic to get first class support for Bazel.
Happy to contribute if you can provide some bootstrap pointers 😄
That Bazel link is a 404, but regardless, if you can provide a way to detect a Bazel project, and a command to run to retrieve the classpath, gluing it into classpath.vim should be pretty straightforward.
All Bazel projects have a WORKSPACE file at their root but I think for detection you would also need to find a BUILD,BUILD.bazel or BUILD.bzl file as a peer to the WORKSPACE file or in a (possibly nested) subdirectory. So when the plugin detects the filetype is java then just walking the tree to find those two things would determine if it is a Bazel project.
Getting the classpath info might be a little tricky because each package could have 0 - n java targets, each target with its own classpath. Something like bazel aquery 'mnemonic("Javac", inputs(".*java", //path/to/package:all))' will give you all the classpath info for all targets but there might be some complex parsing to figure out which java file needs which classpath from the output.
Here's an example output from something I cobbled together that has 2 java targets in its package (ergo 2 separate classpaths and sourcepaths). I'll do some digging to see if I can get a cleaner output from Bazel or via scripting. Let me know if you beat me to it 😃
Activity
tpope commentedon Mar 4, 2020
That Bazel link is a 404, but regardless, if you can provide a way to detect a Bazel project, and a command to run to retrieve the classpath, gluing it into classpath.vim should be pretty straightforward.
ddlees commentedon Mar 6, 2020
Whoops! Fixed that link.
All Bazel projects have a
WORKSPACEfile at their root but I think for detection you would also need to find aBUILD,BUILD.bazelorBUILD.bzlfile as a peer to theWORKSPACEfile or in a (possibly nested) subdirectory. So when the plugin detects the filetype is java then just walking the tree to find those two things would determine if it is a Bazel project.Getting the classpath info might be a little tricky because each package could have
0 - njava targets, each target with its own classpath. Something likebazel aquery 'mnemonic("Javac", inputs(".*java", //path/to/package:all))'will give you all the classpath info for all targets but there might be some complex parsing to figure out which java file needs which classpath from the output.Here's an example output from something I cobbled together that has 2 java targets in its package (ergo 2 separate classpaths and sourcepaths). I'll do some digging to see if I can get a cleaner output from Bazel or via scripting. Let me know if you beat me to it 😃