go.nvim icon indicating copy to clipboard operation
go.nvim copied to clipboard

Inlay hints disappear after saving

Open xtrats opened this issue 1 year ago • 10 comments

Inlay hints are displayed when the file is opened, but they disappear after saving without changing anything. I use init_lazy.lua to make the test.

neovim version: 0.9.5

2024-01-03_20-28-50 (1)

xtrats avatar Jan 03 '24 12:01 xtrats

@xtrats if you really need the go inlay, you can use the inlay from neovim/nvim-lspconfig, and disable go.nvim's inlay.

hoarse-boy avatar Jan 04 '24 07:01 hoarse-boy

@jourdy-mago If I set enable = false of lsp_inlay_hints option in go.nvim, then the go inlay hints doesn't work at all.

Related config is as blow:

ray-x/go.nvim config:

lsp_inlay_hints = {
  enable = false,
}

neovim/nvim-lspconfig config:

opts = {
  inlay_hints = { enabled = true },
  -- ...
}

on_attach function:

if client.server_capabilities.inlayHintProvider then
  vim.lsp.inlay_hint.enable(bufnr, true)
end

xtrats avatar Jan 04 '24 12:01 xtrats

@xtrats my bad, didn’t notice that you have neovim version: 0.9.5. from what i heard neovim/nvim-lspconfig only works on nvim nightly 0.10.

hoarse-boy avatar Jan 05 '24 03:01 hoarse-boy

@jourdy-mago Thanks for the reminder!

xtrats avatar Jan 08 '24 12:01 xtrats

interesting.... so this is because i need to use nvim 0.10 nightly?

Thats great to know because i was just about to ask why everything disappears on save

ill go compile nvim 0.10 hopefully lots of new magic opens up

9mm avatar Jan 19 '24 22:01 9mm

I tried, that was bit of disaster.. will have to table this for now as like 20 other things broke when using neovim 0.10. If anyone ever figures out how to get this to persist on save in meantime id love to hear

9mm avatar Jan 20 '24 00:01 9mm

Also one other thing, even with neovim 0.10 they still disappeared on save

9mm avatar Jan 20 '24 00:01 9mm

@9mm did you use the inlay from neovim/nvim-lspconfig and disable go.nvim's?

you can check my config here. I disabled go.nvim inlay hints and only use inlay from nvim-lspconfig

      require("go").setup({
        lsp_inlay_hints = {
          enable = false,
          style = "inlay",
        },
      })
-- ...
            if client.server_capabilities.inlayHintProvider then
              vim.lsp.inlay_hint.enable(bufnr, true)
            end
-- ...

i have just tested it, the go.nvim inlay is still buggy.

hoarse-boy avatar Apr 17 '24 06:04 hoarse-boy

I am also having the same issue, and I'm using nvim release 0.10.x

Attaching video recording.

https://github.com/ray-x/go.nvim/assets/60306480/ca02f716-f95a-4d82-90cc-42901abce7a6

	{
		"ray-x/go.nvim",
		ft = "go",
		config = function()
			require("go").setup({
				lsp_cfg = true,
				goimports = "gopls", -- goimport command, can be gopls[default] or goimport
				lsp_gofumpt = true, -- true: set default gofmt in gopls format to gofumpt
				lsp_document_formatting = false,
				lsp_on_attach = on_attach, -- use on_attach from go.nvim
				diagnostic = {
					virtual_text = false,
				},
				luasnip = true,
				lsp_inlay_hints = {
					parameter_hints_prefix = "󰊕",
				},
				diagnostic = diagnostic_config,
			})
			local cfg = require("go.lsp").config() -- config() return the go.nvim gopls setup
			require("lspconfig").gopls.setup(cfg)
			vim.diagnostic.config(diagnostic_config)
		end,
		lazy = true,
	},

my lazy nvim configs for ray-x/go.nvim if that helps

tr0b avatar Jun 23 '24 01:06 tr0b

@hoarse-boy If you want to use lsconfig, please disable lsp in go.nvim by setting lsp_cfg=false

ray-x avatar Jun 23 '24 02:06 ray-x