Skip to content
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

Adding inlay_hints since neovim 0.10+ supports it #4509

Open
salimp2009 opened this issue Feb 23, 2024 · 6 comments
Open

Adding inlay_hints since neovim 0.10+ supports it #4509

salimp2009 opened this issue Feb 23, 2024 · 6 comments
Labels
enhancement New feature or request

Comments

@salimp2009
Copy link

salimp2009 commented Feb 23, 2024

Feature Description

Hi
Since inlay_hints is supported by neovim 0.10.+ there should be inlay_hints, toogle and enable/disable inlay_hints .
maybe something like this can be added to on_attach function

if client.supports_method "textDocument/inlayHint" then
    vim.lsp.inlay_hint.enable(bufnr, true)
  end

Also a custom function to toogle it can be added to which_key lsp menu and a way to enable/disable using lvim builtins or lvim.lsp.inlay_hints.enable = true/false for users to easily set it

M.toggle_inlay_hints = function()
 local bufnr = vim.api.nvim_get_current_buf()
 vim.lsp.inlay_hint.enable(bufnr, not vim.lsp.inlay_hint.is_enabled(bufnr))
end

Describe the alternatives you have considered

No response

Support information

No response

@salimp2009 salimp2009 added the enhancement New feature or request label Feb 23, 2024
@VincentVonPark
Copy link

VincentVonPark commented Mar 28, 2024

Sorry to ask of you, could you guide me full content you wrote into where / what files in detail?
Because I added these in config.lua in Lunarvim, but failed to start...


local lspconfig = require('lspconfig')

// Example for 'clangd', replace with your LSP server as necessary
lspconfig.clangd.setup {
-- Other configuration settings...
handlers = {
["textDocument/inlayHint"] = vim.lsp.inlay_hint_handler,
}
}

// Automatically refresh inlay hints

vim.api.nvim_create_autocmd({"BufEnter", "BufWinEnter", "TabEnter", "TextChanged", "InsertLeave"}, {
callback = function()
vim.lsp.inlay_hint.enable(bufnr,true)
end
})


Error Messages are these below...
Error in decoration provider vim_lsp_inlayhint.win:
Error executing lua: .../usr/local/share/nvim/runtime/lua/vim/lsp/inlay_hint.lua:314: assertion failed!
stack traceback:
[C]: in function 'assert'
.../usr/local/share/nvim/runtime/lua/vim/lsp/inlay_hint.lua:314: in function <.../usr/local/share/nvim/runtime/lua/vim/lsp/in
y_hint.lua:305>

@salimp2009
Copy link
Author

I believe it should be in common_on_attach function on line 63 some where within that function.

function M.common_on_attach(client, bufnr)

Similar what is in Launch.nvim
https://github.com/LunarVim/Launch.nvim/blob/master/lua/user/lspconfig.lua#L22

This comment was marked as outdated.

@github-actions github-actions bot added the stale label May 18, 2024
@salimp2009
Copy link
Author

just keeping it alive :)

@github-actions github-actions bot removed the stale label May 19, 2024
@kylo252
Copy link
Collaborator

kylo252 commented May 20, 2024

We can take a vote whether this should be opt-in or not, since not all the servers have useful info to display, but it's definitely a nice feature!

@salimp2009
Copy link
Author

salimp2009 commented May 20, 2024

We can take a vote whether this should be opt-in or not, since not all the servers have useful info to display, but it's definitely a nice feature!

at least we need to give an option to user to enable or disable. But if we dont have it in lvim source , the user will not have that option unless they tweak the lvim code.
it will be similar to format_on_save so user can easliy enable or disable

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants