VidocqH / lsp-lens.nvim

Neovim plugin for displaying references and difinition infos upon functions like JB's IDEA.
MIT License
252 stars 15 forks source link

[Bug] `LspLensOn` has no effect #27

Closed pidgeon777 closed 8 months ago

pidgeon777 commented 8 months ago

I'm testing the plugin with a C source code with clangd enabled.

Nohing changes when LspLensOn is executed.

My Lazy config:

{
  'VidocqH/lsp-lens.nvim',
  config = function()
    require'lsp-lens'.setup({
      enable = true,
      include_declaration = false,      -- Reference include declaration
      sections = {                      -- Enable / Disable specific request
        definition = false,
        references = true,
        implements = true,
      },
      ignore_filetype = {
        -- "prisma",
      },
    })
  end,
  enabled = lvim.builtin.lsp_lens.active,
}

clangd LSP is working as expected, though.

Also I tried with other filetypes, nothing happens.

Neovim version: v0.9.2

jellydn commented 8 months ago

I've got similar issue with Lsp Len and make it works by pin to the commit

 -- disable lsp-inlayhints and lsp lenf if that is nightly version, will remove when 0.10.0 is stable
local is_stable_version = true
if vim.fn.has("nvim-0.10.0") == 1 then
  is_stable_version = false
end

return {
     {
    -- Displaying references and definition infos upon functions
    "VidocqH/lsp-lens.nvim",
    -- Pin to commit due to some breaking changes
    commit = "13d25ad8bd55aa34cc0aa3082e78a4157c401346",
    event = "BufRead",
    -- Disable lsp lens if that is nightly version
    enabled = is_stable_version,
    opts = {
      enable = true,
    },
    keys = {
      {
        -- LspLensToggle
        "<leader>uL",
        "<cmd>LspLensToggle<CR>",
        desc = "LSP Len Toggle",
      },
    },
  }
}
pidgeon777 commented 8 months ago

I confirm that with that commit it works, hopefully this will be fixed in the latest master commit.

mcauley-penney commented 8 months ago

@pidgeon777 I'm not experiencing this issue but decided to look into it. Firstly, I installed v0.9.2 and put in the configuration in the original issue comment. I receive this error:

image

Looking at lsp-lens.nvim/lua/lsp-lens/config.lua, sections are functions, not booleans, hence the error. If I understand correctly, the configuration in the readme is incorrect and the config in the original issue comment has the same problem. Removing the section option or changing the values to functions fixes it for me. Idk if this really solves your problem but please sound off and let me know if modifying that config section does anything for you. If not, more information may be useful.

Edit: Right after I wrote this, I removed your config and went back to mine. I tried it with 0.9.2 and am getting the same issue, where lsp-lens doesn't activate, and all the LspLens... functions are unavailable. Looking into it. I had an error in my config.

VidocqH commented 8 months ago

@pidgeon777 I'm not experiencing this issue but decided to look into it. Firstly, I installed v0.9.2 and put in the configuration in the original issue comment. I receive this error:

image

Looking at lsp-lens.nvim/lua/lsp-lens/config.lua, sections are functions, not booleans, hence the error. If I understand correctly, the configuration in the readme is incorrect and the config in the original issue comment has the same problem. Removing the section option or changing the values to functions fixes it for me. Idk if this really solves your problem but please sound off and let me know if modifying that config section does anything for you. If not, more information may be useful.

Edit: ~Right after I wrote this, I removed your config and went back to mine. I tried it with 0.9.2 and am getting the same issue, where lsp-lens doesn't activate, and all the LspLens... functions are unavailable. Looking into it.~ I had an error in my config.

Sorry for the late reply. It should be fixed now.

jellydn commented 8 months ago

It should be fixed now.

Thanks. It works for me.

daUnknownCoder commented 8 months ago

bro still doesnt work for me, i installed it and tried it first in the lua language, mostly my nvim's config 2023-10-24-233743_hyprshot

lsp_lens is on LspLensOn

i also tried pinning to commit 13d25ad8bd55aa34cc0aa3082e78a4157c401346

VidocqH commented 8 months ago

bro still doesnt work for me, i installed it and tried it first in the lua language, mostly my nvim's config 2023-10-24-233743_hyprshot

lsp_lens is on LspLensOn

i also tried pinning to commit 13d25ad8bd55aa34cc0aa3082e78a4157c401346

Can you try define a non-anonymous function?

function hello()
  print("Hello, World")
end
daUnknownCoder commented 8 months ago
function hello()
  print("Hello, World")
end

2023-10-25-233238_hyprshot

still doesnt work, LspLensOn is enabled

i forgot this earlier, this is my config:

return {
  "VidocqH/lsp-lens.nvim",
  lazy = true,
  event = "LspAttach",
  opts = {
    enable = true,
    commit = "13d25ad8bd55aa34cc0aa3082e78a4157c401346",
    include_declaration = true,
    sections = {
      definitions = true,
    },
  },
}

also tried moving opts inside require("lsp-lens").setup({...})

2023-10-25-233611_hyprshot

mcauley-penney commented 8 months ago

Firstly, "definitions" should be singular , and you may need to wrap the entire plugin in curly braces because plugin defs for Lazy should be a table of tables, I think. I'll test this when I'm available and debug it. I don't believe this is related to this issue, though, because this seems like a configuration error at first glance.

Edit: Your config works for me on nightly, both with and without the commit spec. This seems like a configuration issue, maybe someplace else an issue with something other than what this issue deals with.

daUnknownCoder commented 8 months ago

thanks but i got it to work, even without pinning it to a commit:

2023-10-26-215723_hyprshot

pidgeon777 commented 8 months ago

I confirm the latest commit fixed the issue. This can be closed if needed.