Skip to content

Include LSP Support #68

Open
Open

Description

@beisenherz

There are a few language servers out there for nix. It would be great if you could use those from within JetBrains Products. An example library to do this 'quick' and 'dirty' would be https://github.com/ballerina-platform/lsp4intellij. Other than that, JetBrains Products started allowing plugin developers to communicate with LSPs from the Plugin, starting from 2023.2 (see: Language Server Protocol for Plugin Developers)
Would love to be able to use LSPs in combination with IntelliJ, and thank you in advance for your time :)

Activity

  1. JojOatXGME commented on Sep 4, 2023

    @JojOatXGME
    Contributor

    Hi, do you have some specific LSPs in mind?

    I was not aware of this new functionality in IDEA. Looks like it just got introduced by 2023.2, which means it might be a bit tricky to implement without loosing support for older versions of the IDE. (Usually, I would drop support for older versions in about one year.) I am also a bit confused that the Community Edition of IntelliJ is not listed in the blog post. Anyway, if there is a good LSP, it might be an interesting option.

  2. beisenherz commented on Sep 4, 2023

    @beisenherz
    Author

    There are two LSPs I know of that are somewhat Feature complete. Nil (https://github.com/oxalica/nil) and Nixd (https://github.com/nix-community/nixd).

    I hoped that there could be some "easy" option to make this backwards compatible, like checking if something is available in the classpath. Also I hoped that there would be some easy way to add ultimate features if there it is the IDE. Maybe I'm just plain wrong with my assumptions :) Would love to see this feature and the future :)
    If I can help you in any way just say so :)

  3. JojOatXGME commented on Sep 10, 2023

    @JojOatXGME
    Contributor

    FYI, I tried out the LSP integration of IntelliJ on the lsp branch (build). I did not invest much time into that, but it did seem to work with nil. I also tried nixd, but the LSP implementation of IntelliJ throw an exception due to an unexpected token whenever nixd was not able to resolve a reference. Looks like either nixd or IntelliJ has a bug in the protocol implementation.

    Anyway, it would be more effort to integrate this without removing support for the previous versions of IntelliJ. It is also a bummer that this feature only works with paid versions of IDEA. Maybe I try out lsp4intellij later, but I fear I will not have time for that in the next few weeks.

  4. JojOatXGME commented on Sep 24, 2023

    @JojOatXGME
    Contributor

    I tried out lsp4intellij with nil, but it didn't feel very stable on a first glance. I run into two different NullPointerException and one IllegalArgumentException from within the library within a few minutes of testing.

    • Clicking on the status icon before you have opend any Nix file.
    • Clicking on an identifier, for which the Language Server cannot resolve the definition.
    • Clicking on a variable in a let expression.

    I may look a bit closer, but I am currently a bit sceptical.

    EDIT: FIY, I also pushed the code to the lsp branch again. See commit ac74690.

  5. cottand commented on Jan 16, 2024

    @cottand
    Contributor

    hey @JojOatXGME I think providing LSP support for nix-idea would be huge - the current lack of nixd is the only reason I use VSCode instead of intelliJ for Nix (try it yourself to see the difference!). In every other aspect IntelliJ is better.

    I know nothing about LSPs but I have developed an IDEA plugin before and I am happy to help.

    • For nixd: would it be possible to narrow down what part of the LSP protocol nixd is non-compliant with? Ideally we could get them to fix it or we could just submit a fix with them ourselves
    • For your backwards compatibility concerns - they are totally fair. I suggest maintaining the 'ahead' version of this plugin (with minimum compatible being 2023.2) and we can package it via Nix to make it very easy for other people to install it manually in IDEA, without having to go through the official marketplace. Potentially we could even provide a patched IDEA (from nixpkgs) that comes with nix-idea installed to make this extra easy - but that's a long shot

    What do you think?

  6. JojOatXGME commented on Jan 16, 2024

    @JojOatXGME
    Contributor

    @cottand The main reason why I haven't spent more time on implementing LSP-support using the LSP integration is that it would only work in paid versions of IDEA. I only have the community editions, so I wouldn't be able to use it. I fear JetBrains might be reluctant to put this feature into the community editions, as it would make the premium features less worthwhile.

    If you would like to spend time on this, I would be open to merge the pull request.

    BTW, After my disappointing experiment with lsp4intellij, I also thought about implementing my own LSP integration for a short moment, but then I realized that I don't have time for such a project. 😄

    For nixd: would it be possible to narrow down what part of the LSP protocol nixd is non-compliant with?

    Not sure, I haven't spent much time on debugging the issue.

    For your backwards compatibility concerns

    I am not sure if this would still be a problem as IntelliJ 2024.1 might be released in a few months. Anyway, I don't think that this should block us. We could probably drop support for 2023.1 earlier than usual. (The old version of the plugin would still work for previous versions of IDEA.)

    we can package it via Nix

    Packaging the plugin via Nix is something I would also like to see. However, I think this would be another independent topic. I only spend a limited time thinking about this topic so far. I imagine it might be tricky. Note that the plugin currently uses the official Gradle plugin from JetBrains. This plugin downloads all the dependencies on demand. I am not sure how easy it is to make all of that work in an offline build environment as used by Nix. There are probably some dependencies currently still missing in nixpkgs.

  7. cottand commented on Jan 19, 2024

    @cottand
    Contributor

    BTW, After my disappointing experiment with lsp4intellij, I also thought about implementing my own LSP integration for a short moment, but then I realized that I don't have time for such a project. 😄

    Also completely fair :D

    If you would like to spend time on this, I would be open to merge the pull request.

    Thanks, I will think about it. I had not realised that the community edition does not support LSPs (yet?). FYI as an open source contributor you could request an Ultimate licence.

    We could probably drop support for 2023.1 earlier than usual. (The old version of the plugin would still work for previous versions of IDEA.)

    👍 makes sense

    As for packaging via Nix, I can make a PR if it is something you want and there are benefits for. I think I can manage Gradle if the dependencies are locked, which is usually the case for JARs.

  8. JojOatXGME commented on Jan 20, 2024

    @JojOatXGME
    Contributor

    I had not realised that the community edition does not support LSPs (yet?).

    I hope it is yet. However, I can imagine that they fear that it would diminish the value proposition of the ultimate edition. People could easily start using an LSP for JavaScript and other languages, for which you have to pay right now. I haven't found any specific information about that when I looked into it.

    As for packaging via Nix, I can make a PR if it is something you want and there are benefits for. I think I can manage Gradle if the dependencies are locked, which is usually the case for JARs.

    I personally don't need it right now. So I wouldn't prioritize it that high as long as nobody complains. It just seems strange that this project kind of ignores the packaging process of Nix. Also note that the Gradle plugin org.jetbrains.intellij may download resources directly, bypassing the repository management of Gradle. I think I have seen it in the past. (You can still do it, of course, if you like.)

  9. cottand commented on Jan 21, 2024

    @cottand
    Contributor

    I personally don't need it right now. So I wouldn't prioritize it that high as long as nobody complains.

    done :)

    sounds good, I will consider spending time on this, and we can revisit if JetBrains makes lsp available for the community edition

  10. abovestratosphere commented on Apr 9, 2024

    @abovestratosphere

    hey, i think even releasing a basic version like the one you linked above would be a huge boon (built it myself to try out, and the basic functionality it offers is already satisfactory for most of my needs). I really don't wanna have to switch to vscode just for nix files...

  11. JojOatXGME commented on Apr 9, 2024

    @JojOatXGME
    Contributor

    @abovestratosphere Do you know if you have tried the version with lsp4intellij, or the version using the LSP integration of IDEA? I was not convinced by lsp4intellij as it did throw a lot of exception during my tests. I am probably not able to fix them. However, if you think it is still valuable, I guess I could think about integrating it behind some feature flag.

    Regarding the solution using JetBrains LSP integration (paid versions only): I have recently seen some analytics from JetBrains, and was surprised how many users of the plugin seem to use IntelliJ Ultimate. So, maybe integrating this solution makes more sense as I though initially. I am still only using the community edition, through. 🤷‍♂️ (Do you have a paid version of IDEA?)

  12. abovestratosphere commented on Apr 10, 2024

    @abovestratosphere

    looks like the version i built was e815bfe, all I did was bump the supported IDE version on that commit so it could work for me, so not the lsp4intellij commit. I'm honestly not clear on the difference between using lsp4intellij vs whatever you did in the first commit (not familiar with jetbrains plugin ecosystem at all).
    That being said, your first prototype commit is honestly already a huuuuge improvement (being able to just navigate to a nix file by using the "go to source" hotkey on a file path is already a game changer). The only issue is, without it being officially released, I have to constantly bump the version on it and rebuild, like recently everything got updated to 2024.1 so it broke again, which is a hassle.

    I personally don't use intellij since I dont work in java but my company sponsors all jetbrains licenses, so yes I have all paid jetbrains IDEs.

    FWIW, most folks I know use vscode or neovim for nix (because of lsp support), but I definitely know other diehard jetbrains users who are dying for nix lsp support in this plugin, there's dozens of us :)

  13. added 2 commits that reference this issue on Apr 13, 2024
  14. hab25 commented on Apr 17, 2024

    @hab25

    @abovestratosphere did you use nixd or nil? If nixd, did you run into the issues described by @JojOatXGME, which are seemingly protocol-related?

  15. abovestratosphere commented on Apr 17, 2024

    @abovestratosphere

    I used whatever that commit e815bfe used, which is nil

  16. andrew222651 commented on Apr 24, 2024

    @andrew222651
  17. JojOatXGME commented on Apr 29, 2024

    @JojOatXGME
    Contributor

    I just implemented and released some experimental solution using JetBrains' LSP API. See version 0.4.0.13 and commit cfe2ef1. There are currently no automatic tests, and I only tested the basics manually. I hope everything works.

    Settings page for enabling and configuring the language server

    As it is using JetBrains' API, it only works for paid versions of IDEA. If someone wants to try out https://github.com/redhat-developer/lsp4ij (thanks @amacfie) to make it available for free, I am happy to help. I may also take a look at it at some point, but probably not in the near future.

    PS: During my short tests, I no-longer noticed the exception I have observed with nixd in the past. However, nil still provided a better experience during my tests, as it was more responsive. In contrast to nil, nixd also wasn't able to resolve the paths in the files I used.

  18. abovestratosphere commented on May 1, 2024

    @abovestratosphere

    @JojOatXGME thanks a lot. just tested, it works great for me.

  19. angelozerr commented on May 28, 2024

    @angelozerr
  20. eveeifyeve commented on May 19, 2025

    @eveeifyeve
    Member

    I would be happy to add lsp support via https://github.com/redhat-developer/lsp4ij instead of intellij api since it locks the apis behind paywalls in intellij idea community edition.

  21. JojOatXGME commented on May 21, 2025

    @JojOatXGME
    Contributor

    @eveeifyeve Feel free to work on it. :) I would be happy to merge such feature. I am happy to help if you need any specific guidance. You can probably start with the developer guide of lsp4ij.

    Note that by following the steps described in the document, all users would need to install LSP4IJ as a separate plugin. For the first release, it probably makes sense to make the dependency optional and keep the implementation using JetBrains' API available as well.

  22. angelozerr commented on Jun 26, 2025

    @angelozerr

    @eveeifyeve do you need some help to integrate LSP support with LSP4IJ?

    Please note that LSP4IJ provides also a DAP support, it seems you could use lldb (see https://github.com/redhat-developer/lsp4ij/blob/main/docs/dap/user-defined-dap/swift-lldb.md or codelldb (I need to write doc for that)

  23. JojOatXGME commented on Jul 19, 2025

    @JojOatXGME
    Contributor

    FYI, the built-in LSP-API from JetBrains seems to become free to use with future versions of IntelliJ. (EDIT: Although not open source. You have to install the ultimate edition, which will then be free, as long as you don't need the additional functionality.)

    https://platform.jetbrains.com/t/lsp-api-available-in-intellij-idea-ultimate-2025-2-without-paid-subscription/2284

  24. eveeifyeve commented on Jul 19, 2025

    @eveeifyeve
    Member

    FYI, the built-in LSP-API from JetBrains seems to become free to use with future versions of IntelliJ. (EDIT: Although not open source. You have to install the ultimate edition, which will then be free, as long as you don't need the additional functionality.)

    platform.jetbrains.com/t/lsp-api-available-in-intellij-idea-ultimate-2025-2-without-paid-subscription/2284

    Still either way this is an opensource community, I feel like lsp-4ij will make the intellij plugin more open to the public and use editions like the community edition which is opensource.

  25. added a commit that references this issue on Oct 19, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions