mrcjkb / haskell-tools.nvim

🦥 Supercharge your Haskell experience in neovim!
GNU General Public License v2.0
432 stars 18 forks source link

Duplicate code-lenses #259

Closed TheBlueFireFox closed 10 months ago

TheBlueFireFox commented 10 months ago

Feature description

1) Love the plugin, so thanks for writing and maintining it. 2) Can you add a way to disable the inlay hints? In my setup it clashes with a different plugin (lvimuser/lsp-inlayhints.nvim) and then writes them twice.

Thanks

fyi I am using 2.x.x

image

mrcjkb commented 10 months ago

Hi :wave:

Thanks for the nice words :smile:

I think what you're seeing are code lenses, not inlay hints. Afaik, haskell-language-server doesn't support inlay hints yet: https://github.com/haskell/haskell-language-server/issues/2938

I'm not sure why you're seeing them twice, but you can disable codeLens auto-refresh in haskell-tools with

vim.g.haskell_tools = {
  tools = {
    codeLens = {
      autoRefresh = false,
    },
  },
}
TheBlueFireFox commented 10 months ago

Hello. Thank you very much for the fast answer. This seems to be working for some projects. And in others it completely deactivates the code lenses.

For me it is good enough and as such I am once again want to thank you for your hard work.

mrcjkb commented 10 months ago

Hmm, it sounds like it may be conflicting with another plugin. Which plugins do you have installed?

mrcjkb commented 10 months ago

Or another question: Do the duplicate code lenses disappear when the inlay hints plugin is disabled?

TheBlueFireFox commented 10 months ago

Hallo again

@mrcjkb For the first question I have a few plugins installed the one that I think might be the conflicting one is the (lvimuser/lsp-inlayhints.nvim). For the others I'd have to do some detective work (please tell me what I should search for If so required). (here is my config assuming you'd need it.) About the second yes the duplicate code lenses do disapear when I deactivate the inlay hints plugin.

As always thank you very much for your help. <3

Please tell me if I can help with anything.

mrcjkb commented 10 months ago

I tried to reproduce it using a minimal config based on yours (see README.md#troubleshooting), but couldn't.

The minimal config ```lua -- Minimal nvim config with lazy.nvim -- Assumes a directory in $NVIM_DATA_MINIMAL -- Start with -- -- export NVIM_DATA_MINIMAL=$(mktemp -d) -- export NVIM_APP_NAME="nvim-ht-minimal" -- nvim -u minimal.lua -- -- Then exit out of neovim and start again. -- Ignore default config local config_path = vim.fn.stdpath('config') vim.opt.rtp:remove(config_path) -- Ignore default plugins local data_path = vim.fn.stdpath('data') local pack_path = data_path .. '/site' vim.opt.packpath:remove(pack_path) -- bootstrap lazy.nvim data_path = assert(os.getenv('NVIM_DATA_MINIMAL'), '$NVIM_DATA_MINIMAL environment variable not set!') local lazypath = data_path .. '/lazy/lazy.nvim' local uv = vim.uv ---@diagnostic disable-next-line: deprecated or vim.loop if not uv.fs_stat(lazypath) then vim.fn.system { 'git', 'clone', '--filter=blob:none', 'git@github.com:folke/lazy.nvim.git', '--branch=stable', lazypath, } end vim.opt.rtp:prepend(lazypath) local lazy = require('lazy') lazy.setup({ { 'mrcjkb/haskell-tools.nvim', branch = '2.x.x', dependencies = { 'nvim-lua/plenary.nvim', -- Uncomment or add any optional dependencies needed to reproduce the issue -- 'nvim-telescope/telescope.nvim', -- 'akinsho/toggleterm.nvim', }, ft = { 'haskell', 'lhaskell', 'cabal', 'cabalproject' }, }, { "lvimuser/lsp-inlayhints.nvim", event = { "BufReadPost", "BufNewFile" }, opts = function() vim.api.nvim_set_hl(0, "LspInlayHintCustom", { link = "Comment" }) 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, }) return { inlay_hints = { parameter_hints = { show = true, prefix = "<- ", separator = ", ", remove_colon_start = true, remove_colon_end = true, }, type_hints = { -- type and other hints show = true, prefix = "=> ", separator = ", ", remove_colon_start = true, remove_colon_end = false, }, -- highlight group highlight = "LspInlayHintCustom", }, debug_mode = true, } end, }, -- Add any other plugins needed to reproduce the issue. -- see https://github.com/folke/lazy.nvim#-lazynvim for details. }, { root = data_path, state = data_path .. '/lazy-state.json', lockfile = data_path .. '/lazy-lock.json' }) ```

I also noticed you have the following in your config:

vim.g.haskell_tools = {
    hls = {
        tools = {
             inlay_hints = { auto = true },
        },
        capabilities = require("cmp_nvim_lsp").default_capabilities(),
    },
 }

There's no tools.inlay_hints setting, and the haskell-tools plugin will automatically add cmp_nvim_lsp capabilities if it detects the plugin. So you can remove the init function from your config. I doubt that's what's causing the issue though...

TheBlueFireFox commented 10 months ago

First sorry for the old config state. (I have already removed it locally, but forgot to update it online...)

Secondly I think we can simple close this issue... I am probably the only one who has this issue given my weird setup and I am fine with your solution above to just deactivate the autoreload for the codeLens.

Either way I once again want to thank you for all your effort in both my issue and also the general plugin.

mrcjkb commented 10 months ago

Alright, I'll close this for now :smile:

By the way, it looks like inlay hints will be supported natively in neovim 0.10: https://github.com/neovim/neovim/pull/23984