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

[FEAT] Support Bazel #68

Open
ddlees opened this issue Mar 4, 2020 · 10 comments
Open

[FEAT] Support Bazel #68

ddlees opened this issue Mar 4, 2020 · 10 comments
Labels
help wanted Extra attention is needed

Comments

@ddlees
Copy link

ddlees commented Mar 4, 2020

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 😄

@chemzqm chemzqm added the help wanted Extra attention is needed label Mar 5, 2020
@chemzqm
Copy link
Member

chemzqm commented Mar 5, 2020

Sorry, I don't have any experience with Bazel, looks like jdt.js should support that at first.

@ddlees
Copy link
Author

ddlees commented Mar 6, 2020

I checked the jdt.ls github page and they do have an issue open, however, it looks like the Bazel core team has been able to create plugins for eclipse and intellij that also leverage the jdt.ls. I have to imagine we could do the same with this lovely extension 😉

I opened a request against vim-classpath to do something similar which coc-java could leverage or piggyback on. Normally I would just give up and just do all my Java coding (...ew) in IntelliJ but I actually have time to try and do something about this for the coc community. Let me know what I can do.

@gibfahn
Copy link

gibfahn commented Jan 29, 2021

I think the likely path forwards would be to have a coc-bazel that wraps the WIP Bazel language server: https://github.com/bazelbuild/vscode-bazel

@GregBowyer
Copy link

I think salesforce did most of the leg work here

https://github.com/salesforce/bazel-vscode

@GregBowyer
Copy link

GregBowyer commented Sep 17, 2021

So with incredible hacking I might have something that is starting to work

  1. Build that vscode project
  2. Extract the archive and take the two jars
  3. Put those jars in the jdt home where all the jars are
  4. Include the jars in the config_linux bit as classpath files
  5. Change https://github.com/neoclide/coc-java/blob/master/package.json to allow java.import.bazel.enabled

2021-09-16-193445_1752x804_scrot

There is still a lot that is broken but a bunch of things started working for me

@igbanam
Copy link

igbanam commented Sep 1, 2022

Hi all,

Wanted to being this back up since support for Bazel has been built into eclipse.jdt.ls eclipse-jdtls/eclipse.jdt.ls#543

Is this something that can be done now?

@adarsh-murthy
Copy link

My team uses bazel too and this would be super helpful for me. Thanks!

@igbanam
Copy link

igbanam commented May 4, 2023

Hey @adarsh-murthy …and friends 🙂

Bazel is now supported. I have confirmed this from OpenJDK 17 (minimum) to the current OpenJDK 20. You can test this out as well with the project at bazelbuild/java-tutorial.

Bazel is highly configurable. So if you're using Bazel in an enterprise setting, there are most likely configurations which shift Bazel away from its vanilla setup. Nothing to worry though, you just have to learn how your company sets up Bazel and configure your setup to account for those. One recent example I solved is using java.project.referencedLibraries to inform coc.nvim about classes auto-generated from .proto schemas. There are many keys in the config which could solve your issue as well.

p.s: even if your company lags behind on the version of Java used for their products — which most enterprise companies do, by design — it's possible to have your Java version be closer to the bleeding edge for your LSP

@adarsh-murthy
Copy link

adarsh-murthy commented May 5, 2023

Thanks for the timely response.
I see that coc-java works really well for the project you linked but it's not working for the project I have at work. I keep getting the error [coc.nvim] definition not found. It doesn't even go to definition for a variable that's defined in the same file. Here is the log:

2023-05-05T02:13:00.792 INFO (pid:2903414) [plugin] - coc.nvim initialized with node: v18.13.0 after ^[[33m207^[[39m
2023-05-05T02:13:04.427 INFO (pid:2903414) [services] - LanguageClient ciderlsp state change: stopped => starting
2023-05-05T02:13:04.660 INFO (pid:2903414) [language-client-index] - Language server "languageserver.ciderlsp" started with 2903610
2023-05-05T02:13:04.721 INFO (pid:2903414) [attach] - receive notification: highlight []
2023-05-05T02:13:05.663 INFO (pid:2903414) [services] - LanguageClient Language Support for Java state change: stopped => starting
2023-05-05T02:13:05.674 INFO (pid:2903414) [language-client-index] - Language server "java" started with 2903851
2023-05-05T02:13:05.701 INFO (pid:2903414) [attach] - receive notification: highlight []
2023-05-05T02:13:06.567 INFO (pid:2903414) [services] - LanguageClient ciderlsp state change: starting => running
2023-05-05T02:13:06.579 INFO (pid:2903414) [services] - service languageserver.ciderlsp started
2023-05-05T02:13:06.781 ERROR (pid:2903414) [provider-manager] - Provider error on provideDocumentLinks: Canceled: Canceled
      at Nd.handleFailedRequest (/.vim/plugged/coc.nvim/build/index.js:248:966)
      at /.vim/plugged/coc.nvim/build/index.js:239:19020
      at async /.vim/plugged/coc.nvim/build/index.js:215:27498
      at async Promise.allSettled (index 0)
      at async tf.provideDocumentLinks (/.vim/plugged/coc.nvim/build/index.js:215:27432)
      at async K1.getDocumentLinks (/.vim/plugged/coc.nvim/build/index.js:257:28420)
      at async gI.getLinks (/.vim/plugged/coc.nvim/build/index.js:269:4960)
2023-05-05T02:13:06.982 INFO (pid:2903414) [attach] - receive notification: highlight []

@igbanam
Copy link

igbanam commented May 10, 2023

I couldn't find ciderlsp anywhere mainstream. From what I read, it's a Clojure LSP. Checkout coc-clojure — I don't see coc-java in the logs; and it may not work for Clojure projects.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

6 participants