williamboman / mason.nvim

Portable package manager for Neovim that runs everywhere Neovim runs. Easily install and manage LSP servers, DAP servers, linters, and formatters.
Apache License 2.0
7.84k stars 276 forks source link

Add support for Sonarlint #247

Closed ChristianChiarulli closed 1 year ago

ChristianChiarulli commented 2 years ago

I've searched open issues for similar requests

Is your feature request related to a problem? Please describe.

I would like sonar lint

Describe the solution you'd like

I would like sonar lint

Describe potential alternatives you've considered

No response

Additional context

https://github.com/SonarSource/sonarlint-language-server

^^ link to the language server

teddy2104 commented 2 years ago

Hi Christian! How do you use Sonarlint in neovim?

williamboman commented 2 years ago

Hey! So it seems like the server is hard-coded to only communicate over TCP (as opposed to stdio, which is the only transport mechanism supported by Neovim's LSP client). There seems to have been a PR to lspconfig where they seem to leverage netcat to work around this. It was closed for some reason though.

I think it'd make sense to try to get the server added to lspconfig first, before considering adding it here, so if someone wants to pick that up again would be great!

williamboman commented 2 years ago

TCP support has been added in core. For now it's only available via the vim.lsp.start API (not lspconfig).

schrieveslaach commented 1 year ago

FYI, I implement the basic Stdio channel in Sonarlint (see https://github.com/SonarSource/sonarlint-language-server/pull/187) and I'm trying to come up with some Lua code to get Sonarlint running within Neovim. However, looks like that it requires a lot of information to be sent from the client.

dav1d-wright commented 1 year ago

Today s a good day to be looking at this Issue, thrilled to see your work on the sonarlint-language-server repo! Looking forward to using this in my work setup, hopefully soon :+1:

schrieveslaach commented 1 year ago

@dav1d-wright, thanks for these kind words.

With a version of the sonarlint-language-server branch you can use my new sonarlint.nvim. Python analyzer works, Java not yet. I think I have a solution in mind to get the Java anlyzer working.

dav1d-wright commented 1 year ago

@schrieveslaach Thank you so much for your work on this! I am afraid that I am using sonarlint for C++ at work, which does not seem to be supported yet. I hope I'll find some time to look into this :slightly_smiling_face:

huesersohn commented 1 year ago

@williamboman I'm thinking about adding SonarLint to lspconfig and here, now that @schrieveslaach has added stdio support. How would you handle the analyzers? Should they all be downloaded together with SonarLint itself (the VSCode Extension does ship with some bundled)? Or should the user configure them by hand? Or should they be separate packages although they depend on this?

schrieveslaach commented 1 year ago

@huesersohn, please note that not all analyzers just work because there has to be some dance with the LSP client. For example, the Java analyzer needs extra responses with classpath information etc. I started a new Neovim plugin for that (see sonarlint.nvim). I'm waiting for the official release of Sonarlint-LS and then I'll continue with adding Java support to the plugin.

huesersohn commented 1 year ago

@schrieveslaach Yes, I've used your plugin successfully with your branch with stdio support. Is your plan to implement the download/installation of SonarLint and the analyzers in your plugin? My idea was to just download the same prebuilt jars (and maybe the other languages not supported yet) that the VS Code extension uses.

schrieveslaach commented 1 year ago

I didn't plan to implement downloading in sonarlint.nvim. For my dotfiles I wanted to integrate the download into my chezmoi setup.

schrieveslaach commented 1 year ago

FYI, got working Java support:

ezgif-2-0ff4794c7b

krishnakumarg1984 commented 1 year ago

I'm waiting for the official release of Sonarlint-LS

@schrieveslaach I am slightly confused by the above statement. I thought there have been periodic official releases of the Sonarlint-LS?

schrieveslaach commented 1 year ago

@krishnakumarg1984, sorry, I didn't want to confuse anybody. Maybe, the updated README.md of sonarlint.nvim helps: https://gitlab.com/schrieveslaach/sonarlint.nvim

Basically, I wanted to wait for an official release because development versions of sonarlint-ls may rely on unpublished Maven dependencies (see comments in sonarlint-language-server PR).

williamboman commented 1 year ago

Added in https://github.com/mason-org/mason-registry/pull/1294

reisnobre commented 1 year ago

@williamboman question. I'm trying to make use of this, but going to /home/user/.local/share/lvim/mason/bin and running the sonarlint-language-server it says this: The operation couldn’t be completed. Unable to locate a Java Runtime. but on their documentation it says that the vscode version comes with it own JRE thing, do I need to install the JRE way or there's something wrong that I'm doing?

williamboman commented 1 year ago

@reisnobre Yeah it's currently packaged in such a way that it requires JRE on the system. I remember seeing that they provide self-hosted JRE but decided to not use that because it would incur a ~50% larger disk footprint.

reisnobre commented 1 year ago

@williamboman the sonarlint-analyzers are also not on mason package right? this project https://gitlab.com/schrieveslaach/sonarlint.nvim points that it would be at "$MASON/share/sonarlint-analyzers/" but I also can't find the folder for it