-
Notifications
You must be signed in to change notification settings - Fork 2.1k
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
LspInfo for Java based LSP shows OpenJDK version (use serverInfo.version
instead?)
#3509
Comments
Known issue. Would need to make the logic smarter so that it can guess that |
Oh, @justinmk, did I miss an open issue and should I close this one? |
I just stumbled across |
Nice! Not sure how I missed that. We should definitely try to use that instead. |
serverInfo.version
instead?)
Happy that I made I helpful comment. 😉 |
Would it make sense to do something like this in core (I can create a PR for discussion if it looks interesting)? diff --git a/runtime/lua/vim/lsp/client.lua b/runtime/lua/vim/lsp/client.lua
index 72043c18dd..92337b5076 100644
--- a/runtime/lua/vim/lsp/client.lua
+++ b/runtime/lua/vim/lsp/client.lua
@@ -174,6 +174,10 @@ local validate = vim.validate
--- capabilities.
--- @field server_capabilities lsp.ServerCapabilities?
---
+--- Response from the server sent on `initialize` describing information about
+--- the server.
+--- @field server_info lsp.ServerInfo?
+---
--- A ring buffer (|vim.ringbuf()|) containing progress messages
--- sent by the server.
--- @field progress vim.lsp.Client.Progress
@@ -556,6 +560,10 @@ function Client:initialize()
self.offset_encoding = self.server_capabilities.positionEncoding
end
+ if result.serverInfo then
+ self.server_info = result.serverInfo
+ end
+
if next(self.settings) then
self:notify(ms.workspace_didChangeConfiguration, { settings = self.settings })
end
diff --git a/runtime/lua/vim/lsp/health.lua b/runtime/lua/vim/lsp/health.lua
index d2cf888d89..26018710fe 100644
--- a/runtime/lua/vim/lsp/health.lua
+++ b/runtime/lua/vim/lsp/health.lua
@@ -40,6 +40,7 @@ local function check_active_clients()
local clients = vim.lsp.get_clients()
if next(clients) then
for _, client in pairs(clients) do
+ local server_version = vim.tbl_get(client, 'server_info', 'version') or 'n/a'
local cmd ---@type string
local ccmd = client.config.cmd
if type(ccmd) == 'table' then
@@ -62,6 +63,7 @@ local function check_active_clients()
end
report_info(table.concat({
string.format('%s (id: %d)', client.name, client.id),
+ string.format('- Version: %s', server_version),
dirs_info,
string.format('- Command: %s', cmd),
string.format('- Settings: %s', vim.inspect(client.settings, { newline = '\n ' })),
|
yes. |
Description
sonarlint.nvim is a LSP that is based on Java which needs to be started with
java -jar path/to/the/lsp.jar …more options…
and when invoking:LspInfo
it prints the Java version instead of the version of sonarlint-language-server becausenvim-lspconfig
invokesjava --version
which leads to following output:The
--version
flag has been introduced to sonarlint-language-server via SonarSource/sonarlint-language-server#402, succeeded by SonarSource/sonarlint-language-server#410, andnvim-lspconfig
needs to invokejava -jar path/to/the/lsp.jar --version
.Do you think there is a way to make
nvim-lspconfig
aware of such situations?The text was updated successfully, but these errors were encountered: