lvimuser / lsp-inlayhints.nvim Goto Github PK
View Code? Open in Web Editor NEWLicense: Apache License 2.0
License: Apache License 2.0
error msg:
Error executing vim.schedule lua callback: ...sp-inlayhints.nvim/lua/lsp-inlayhints/handler_helper.lua:89: attempt to index field 'inlay_hints' (a nil value)
stack traceback:
...sp-inlayhints.nvim/lua/lsp-inlayhints/handler_helper.lua:89: in function 'render_hints'
...cker/opt/lsp-inlayhints.nvim/lua/lsp-inlayhints/core.lua:235: in function 'handler'
...cker/opt/lsp-inlayhints.nvim/lua/lsp-inlayhints/core.lua:264: in function 'handler'
/usr/share/nvim/runtime/lua/vim/lsp.lua:1371: in function ''
vim/_editor.lua: in function <vim/_editor.lua:0>
my lsp config
function M.on_attach(client, bufnr)
require "lsp-inlayhints".on_attach(client, bufnr)
local bufopts = { noremap = true, silent = true, buffer = bufnr }
vim.keymap.set("n", "<A-d>", vim.lsp.buf.definition, bufopts)
vim.keymap.set("n", "<A-=>", vim.lsp.buf.format, bufopts)
vim.keymap.set("n", "<A-s>", vim.lsp.buf.signature_help, bufopts)
require "aerial".on_attach(client, bufnr)
end
Inline virtual text will soon be merged into master: neovim/neovim#23426
This Plugin is of course the perfect candidate for implementing this feature.
I'm posting this mostly because I was googling and couldn't find a quick answer so hopefully for future googlers this will be helpful.
I dumped the client response (and made sure we don't set a length limit anywhere), and eventually found the implementation PR for tsserver and took a look, they set 30 as a hard limit, no idea why or whether it will change (I asked)
Perhaps it can be helpful to edit the README to let users know.
It would be great to have a screenshot in the readme, that makes the whole thing way more attractive to people ;-)
I am on the anticonceal branch, and the current default style is like the following: : ReturnType <- (args...)
I would like it to be the style of rust-tools, where it depends if there's arguments or not (and I'd like to remove the first colon)
with args: <- (args...) => ReturnType
without args: => ReturnType
let me know if this is possible, and if so, how, thanks!
Hi! I would like to package this project for Arch Linux.
Do you have plans for creating releases for this project? This would be a requirement for allowing us to use verifiable tarballs and create system packages from them.
It would be nice to be able to toggle the hints on a per-buffer basis. Sometimes they are annoying, sometimes not. It would be helpful to be able to turn them off for an individual buffer only.
Thanks for your hard work on this great plugin!
๐๐ป
Just a quick comment to say I've realised this plugin (great as it is) doesn't, in Go at least, display the complete type information.
So for example...
So unless I actually K
over the method I won't know what w
actually is.
In other examples, I also noticed the output type isn't presented...
So for this ^^ the output from the method is a boolean (hence it's used inside of an if
condition) but it's not shown at all, only the input for the method is hinted.
Not sure if there's a configuration issue on my side that's causing this?
https://github.com/Integralist/nvim/blob/main/lua/plugins/lsp.lua#L110-L115
Thanks for any help/guidance you can give me.
Hi @lvimuser, thank you for creating such a useful plugin. I have been enjoying using it with LazyVim. However, I have encountered an issue where sometimes files get attached to null-ls instead of the LSP that provides inlay hints. Currently, I am resolving this issue by modifying the code to check for null-ls clients and assign the first non-null-ls client found. While this solution works for me, I am unsure if there is a better way to handle multiple LSP clients.
Here is the code I added to the plugin:
if store.b[bufnr].client.name == "null-ls" then
for _, client in pairs(vim.lsp.get_active_clients { bufnr = bufnr }) do
if client.name ~= "null-ls" then
store.b[bufnr].client = { name = client.name, id = client.id }
end
end
end
If you think this solution is appropriate, I can create a pull request to implement it and resolve this issue. Thank you for your consideration.
I just deleted the entire return statement that is more than 1000 lines in this code. And I saw this error.
If it's not an important piece of code you can consider making it silent.
The information overload is sometimes quite real for me, and I was thinking that it may be a nice idea to only show the inlay for the current cursor line. Do you think that's possible?
how to disable specific lsp with setup. not use commd
Just checked with python and both the language servers don't provide the InlayHints.
I believe the title itself its very explanatory. I can take the time to create both commands but created the issue for asking about a couple of things:
init.lua
?rust-tools.nvim
's returning an error for type hints to me, so I've tried to setup this plugin. Here is my config:
local server_configs = {
["clangd"] = {
--- ....
},
["rust-analyzer"] = {
imports = {
granularity = {
group = "module",
},
prefix = "self",
},
cargo = {
buildScripts = {
enable = true,
},
},
procMacro = {
enable = true,
},
inlayHints = {
enabled = true,
typeHints = {
enable = true,
},
},
},
}
Here is my lsp setup & attach event:
mason_lsp.setup_handlers({
function(svr)
lsp_cfg[svr].setup({
on_attach = function(_, _) end,
capabilities = capabilities, -- global to `lspserver.protocol.make_client_capabilities()`
settings = server_configs[svr],
})
end,
})
require("lsp-inlayhints").setup()
require("vim").api.nvim_create_augroup("LspAttach_inlayhints", {})
require("vim").api.nvim_create_autocmd("LspAttach", {
group = "LspAttach_inlayhints",
callback = function(args)
if not (args.data and args.data.client_id) then
return
end
local bufnr = args.buf
local client = require("vim").lsp.get_client_by_id(args.data.client_id)
require("lsp-inlayhints").on_attach(client, bufnr)
require("nvim-navic").attach(client, bufnr)
end,
})
The parameter name hints is working, but the type hints seem to handle each token as a different type:
Hi,
I've setup your plugin for Lua and Tsserver, working well.
But when I want to setup it for clangd, i can't get it to work.
Clangd v15.0.6.
After readings docs links you provided I ended up with this configuration :
settings = {
InlayHints = {
Enabled = true,
ParameterNames = true,
DeducedTypes = true,
},
},
Here is the plugin configuration :
require("lsp-inlayhints").setup()
vim.api.nvim_create_augroup("LspAttach_inlayhints", {})
vim.api.nvim_create_autocmd("LspAttach", {
group = "LspAttach_inlayhints",
callback = function(args)
if not (args.data and args.data.client_id) then
return
end
local bufnr = args.buf
local client = vim.lsp.get_client_by_id(args.data.client_id)
require("lsp-inlayhints").on_attach(client, bufnr)
end
})
And my on_attach :
M.on_attach = function(client, bufnr)
require("lsp-inlayhints").on_attach(client, bufnr)
lsp_signature.on_attach({
......
end
return M
I also go this errors in my lsp logs :
Don't know what I'am missing
Hey ๐๐พ
Thanks for this nice standalone plugin. ๐๐พ
I'm wondering why this doesn't work for Java with the Eclipse JDTLS server. According to their code and CHANGELOG they have support for parameter inlay hints. But they don't show up. I'm very certain that my server version is recent enough (--version
output it weird). But I'm wondering if I need to enable a setting or so.
Unfortunately I'm a bit clueless. Any experience or hints?
Hints render at the end of the line, instead of inline. I'm using neovim 0.8.0 (stable release).
My config:
require("lsp-inlayhints").setup()
vim.api.nvim_create_autocmd("LspAttach", {
callback = function(args)
if not (args.data and args.data.client_id) then
return
end
local bufnr = args.buf
local client = vim.lsp.get_client_by_id(args.data.client_id)
require("lsp-inlayhints").on_attach(client, bufnr)
end,
desc = "lsp-inlayhints",
})
Screenshot:
Any ideas what could be wrong?
If a server implements inlay hints on a different endpoint/method (not textDocument/inlayHints), raise an issue with the request/response details to check the possibility of a workaround.
The endpoint in LSP spec is textDocument/inlayHint
Inlay Hint request
When enabled_at_startup
is false in setup, calling require"lsp-inlayhints".toggle()
doesn't seem to do anything. Which means I cannot on-demand load the inlay hints.
As a work-around I've set enabled_at_startup
to true and manually calling toggle()
once to hide them. The attach on the LSP happens on a different file not depicted in this config.
local M = {}
function M.setup()
require("lsp-inlayhints").setup {
enabled_at_startup = true,
debug_mode = true,
}
-- Disable inlay-hints at startup since the config option doesnt seem to work
require("lsp-inlayhints").toggle()
local utils = require "tt.utils"
utils.map("n", "<leader>it", require("lsp-inlayhints").toggle, { desc = "Toggle LSP inlay hints" })
end
return M
Am I missing something or this setting just doesn't work?
I've tried to google and search and figure this out but I can't seem to figure out what I'm doing wrong.
I have installed and configured this but don't seem to be getting any inlay hints. I've tried a few different languages (php, typescript, lua, go) and I'm not getting anything for any of them.
I have an nvchad-based neovim setup (https://nvchad.com/).
My full, custom config is here (https://github.com/nerdo/nvchad-customizations)
The setup code I have for inlayhints is this:
require('lsp-inlayhints').setup()
vim.api.nvim_create_augroup("LspAttach_inlayhints", {})
vim.api.nvim_create_autocmd("LspAttach", {
group = "LspAttach_inlayhints",
callback = function(args)
if not (args.data and args.data.client_id) then
return
end
local bufnr = args.buf
local client = vim.lsp.get_client_by_id(args.data.client_id)
require("lsp-inlayhints").on_attach(client, bufnr)
end,
})
I pretty much copied and pasted from the lsp inlayhints page as far as a config for neovim 0.8+.
I've put in a debug print right before the on_attach
call to ensure it's getting to that point, and it is.
But I don't seem to see any difference when this plugin is installed and running, even after toggling it with lua require('lsp-inlayhints').toggle()
.
Can someone point me in the right direction? What am I doing wrong?
is there any options can make inlay hints like jetbrains intelij stuff? like in C programming
printf("Hello") will become printf(_Format:
"Hello")
Before calling the on-attach function, I want to be able to see if the server supports inlayHints.
I can of course define a hard-coded list, but is there a way to query the language server and tell if it provides inlay hints?
something like:
check_capability({
bufnr = bufnr,
client = client,
capability = "textDocument/inlayHint"
})
Thanks.
main
is working well but ``anitconceal` didn't.
What I wanna see is that something like Jetbrain's inlay hint style but they shown at the end of line
Hello ๐๐ป
I'm using this plugin with gopls
and I noticed that the inlay hints appear incomplete (unless this is by design).
For example, in the following screenshot, we can see the function validatePEMBlocks
accepts an argument pemType
of type string
and so I expected the inlay hint to be <- (pemType string)
but it's just <- (pemType)
.
Hi,
Does this support Python type hints with pyright? I don't know how to enable this..
This is the only reason I still couldn't remove CoC so any help will be very appreciated!!
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.