Giter Site home page Giter Site logo

lsp-inlayhints.nvim's People

Contributors

110y avatar alex-popov-tech avatar bennypowers avatar brian14708 avatar camiloaromero23 avatar christianchiarulli avatar danidsnk avatar dsully avatar indianboy42 avatar lvimuser avatar maxverevkin avatar mehalter avatar niklasmohrin avatar polyzen avatar vidocqh avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

lsp-inlayhints.nvim's Issues

`require('lsp-inlayhints').toggle()` cause Error

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

How to change formatting style to be like rust-tools?

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!

Releases for packaging

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.

Provide ability to toggle on a per-buffer basis

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!

Doesn't display complete type information

๐Ÿ‘‹๐Ÿป

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...

Screenshot 2024-01-15 at 10 21 50

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...

Screenshot 2024-01-15 at 10 24 20

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.

Files attached to null-ls instead of the LSP providing inlay hints

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.

Extra whitespace on rust-analyzer (anticonceal)

I don't know whether this bug is from the neovim PR or the plugin, but i just report it anyway. Feel free to close this if i'm wrong.

Looks like it only happens on newly defined variable type hint

image

Create commands for Toggling and Resetting 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:

  1. Is it better if I create a file for the commands or can I create them in an already existing file (which one)?
  2. Where can I require the existing changes if they are from a new file? In the init.lua?

`rust-analyzer`: type hints joined with `, `

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:

issue

Can't get Inlay Hints to work with clangd

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 :
Screenshot from 2022-12-08 20-20-29

Don't know what I'am missing

Experience with Java language server?

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 show at the end of the line

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:

image

Any ideas what could be wrong?

Docs: LSP Endpoint typo

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

enabled_at_startup doesn't seem to work correctly

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?

Can't seem to get inlay hints to show up

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?

Inlay Hints style like JetBrains Soft

is there any options can make inlay hints like jetbrains intelij stuff? like in C programming
printf("Hello") will become printf(_Format:"Hello")

How can I check dynamically for inlayHints?

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.

Possibly incomplete parameter inlay hint?

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).

Screenshot 2022-08-17 at 09 21 07

Help for Python

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!!

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.