Closed ishanjain28 closed 1 year ago
It seems this was introduced by https://github.com/rust-lang/rust-analyzer/pull/13699
I fixed this by setting rust-analyzer.inlayHints.locationLinks
to false
It seems this was introduced by rust-lang/rust-analyzer#13699 I fixed this by setting
rust-analyzer.inlayHints.locationLinks
tofalse
This doesn't seem to work for me unfortunately, maybe I've set the setting in a wrong way.
@owittek make sure you are setting it like this
rust_tools.setup({
server = {
settings = {
["rust-analyzer"] = {
inlayHints = { locationLinks = false },
},
},
},
})
server = { settings = { ["rust-analyzer"] = { inlayHints = { locationLinks = false }, }, }, },
unfortunately still broken for me, I'm using AstroNvim so I integrated it like that and tried some other things too:
["simrat39/rust-tools.nvim"] = {
after = "mason-lspconfig.nvim",
config = function()
require("rust-tools").setup {
server = astronvim.lsp.server_settings "rust_analyzer" {
settings = {
["rust-analyzer"] = {
inlayHints = { locationLinks = false },
},
},
},
}
end
},
PS: sorry about the formatting, I have no clue why my LSP formats it like that lmao
I am not familiar with astronvim, but looking at the docs, I don't think that's how server_settings are supposed to be used
you might need to configure lsp["server-settings"].rust_analyzer
in the astronvim config instead and do something like this
rust_tools.setup({
server = {
settings = astronvim.lsp.server_settings("rust_analyzer"),
},
})
I am not familiar with astronvim, but looking at the docs, I don't think that's how server_settings are supposed to be used
you might need to configure
lsp["server-settings"].rust_analyzer
in the astronvim config instead and do something like thisrust_tools.setup({ server = { settings = astronvim.lsp.server_settings("rust_analyzer"), }, })
oh yeah by that I'm assuming that I'm assuming that I can put
return {
inlayHints = { locationLinks = false },
}
in server-settings/rust-analyzer.lua but it doesn't work.
@owittek I use AstroNvim too, here's how I fixed it.
My user/plugins/init.lua
:
["simrat39/rust-tools.nvim"] = {
after = { "mason-lspconfig.nvim" },
ft = { "rust" },
config = function() require("rust-tools").setup(require "user.plugins.rust-tools") end,
},
My user/plugins/rust-tools.lua
:
return {
server = astronvim.lsp.server_settings "rust_analyzer",
}
My user/lsp/server-settings/rust_analyzer.lua
:
return {
settings = {
["rust-analyzer"] = {
-- HACK: https://github.com/simrat39/rust-tools.nvim/issues/300
inlayHints = { locationLinks = false },
},
},
}
@wizard-28 Thanks, it worked! I'm too inexperienced in lua so I formatted my server-settings in a wrong way :D
@owittek make sure you are setting it like this
rust_tools.setup({ server = { settings = { ["rust-analyzer"] = { inlayHints = { locationLinks = false }, }, }, }, })
Thanks!
Hey, This is crashing constantly at this line,
with the error, "Expected string, Got Table`.
It tries to read the string in
o_hint.label
but this field not a string anymore for some reason? It now looks like,o_hint.label.value
.I am using latest rust nightly, latest rust analyzer and
neovim-nightly-bin 0.9.0+dev+546+g98daaa798-1
.I tried this patch. It's not crashing any more but I don't really know which hints this code is responsible for and if it's still working thinking I'll take a deeper look tomorrow, for now this makes it usable shrug
-- show other hints with commas and a thicc arrow if not vim.tbl_isempty(other_hints) then virt_text = virt_text .. opts.other_hints_prefix for i, o_hint in ipairs(other_hints) do if o_hint.label.value == nil then goto skip_to_next end if string.sub(o_hint.label.value, 1, 2) == ": " then virt_text = virt_text .. o_hint.label:sub(3) else virt_text = virt_text .. o_hint.label end if i ~= #other_hints then virt_text = virt_text .. ", " end ::skip_to_next:: end end
Would it be worth it to use your patch for a PR?
@TornaxO7 There's an open PR from 2 weeks ago: https://github.com/simrat39/rust-tools.nvim/pull/296#issue-1499492250
but it seems to fix something else, if I'm seeing that correctly and the PR doesn't fix my issue here :(
Oh I checked the changes but since I don't know the source code I assumed by the title that it references the same issue and that the author of the PR simply found the cause on a lower layer.
@SDGLBL could you please tell us if this is related?
i seem to be having the same issue. and as a result im unable to use it.
My config (im using lsp-zero)
-- LSP Rust Settings
local lsp_rust = lsp.build_options('rust_analyzer', {
settings = {
["rust_analyzer"] = {
checkOnSave = {command = "clippy"},
inlayHints = {locationLinks = false}
}
}
})
require("rust-tools").setup({server = lsp_rust})
Oh I checked the changes but since I don't know the source code I assumed by the title that it references the same issue and that the author of the PR simply found the cause on a lower layer.
@SDGLBL could you please tell us if this is related? It seems that my pull request has nothing to do with this issue. And I found that rust-tools.nvim no longer needed my pull request after updating the latest rust-analyzer. So I'll turn it off later.
@reji-zero might be a typo ["rust_analyzer"]
-> ["rust-analyzer"]
Should be fixed by this PR https://github.com/simrat39/rust-tools.nvim/pull/307
Hey, This is crashing constantly at this line, https://github.com/simrat39/rust-tools.nvim/blob/99fd1238c6068d0637df30b6cee9a264334015e9/lua/rust-tools/inlay_hints.lua#L216
with the error, "Expected string, Got Table`.
It tries to read the string in
o_hint.label
but this field not a string anymore for some reason? It now looks like,o_hint.label.value
.I am using latest rust nightly, latest rust analyzer and
neovim-nightly-bin 0.9.0+dev+546+g98daaa798-1
.I tried this patch. It's not crashing any more but I don't really know which hints this code is responsible for and if it's still working :thinking: I'll take a deeper look tomorrow, for now this makes it usable :shrug: