folke / lazydev.nvim

Faster LuaLS setup for Neovim
Apache License 2.0
717 stars 7 forks source link

bug: __index isn't recognized properly #74

Closed nickkadutskyi closed 2 weeks ago

nickkadutskyi commented 2 weeks ago

Did you check docs and existing issues?

Neovim version (nvim -v)

0.10.1

Operating system/version

macOS 15.0.1

Describe the bug

When I do trouble.next({ skip_groups = true, jump = true, mode = "diagnostics" }) I get it highlighted as DaignosticUnderlineWarning with two messages:

But when I do trouble._action("next")({ skip_groups = true, jump = true, mode = "diagnostics" }) it works file.

It seems like when it looks for trouble.something it finds it properly in api.lua via index but if something is missing in api.lua it should go for another index and to call _action function but this time it doesn't work like that and looks for something in actions.lua.

Without lazydev.nvim it doesn't show anything.

See Repro for code example

Steps To Reproduce

  1. Have a call to require('trouble').next({})
  2. Get warning diagnostic highlight with a message saying that you provided wrong params

Expected Behavior

It should not look for next() in actions.lua but instead treat it as a call to _action('next')() from api.lua. (I actually don't know what would be the best way to treat it)

Repro

vim.env.LAZY_STDPATH = ".repro"
load(vim.fn.system("curl -s https://raw.githubusercontent.com/folke/lazy.nvim/main/bootstrap.lua"))()

require("lazy.minit").repro({
  spec = {
    { "folke/lazydev.nvim", opts = {} },
    {
      "folke/trouble.nvim",
      opts = { },
      config = function(_, opts)
        local trouble = require("trouble")
        trouble.setup(opts)
        local toggle_problems = function()
            local buf_name = vim.api.nvim_buf_get_name(0)
            if buf_name ~= "" then
                trouble.open({ mode = "diagnostics", focus = true, filter = { buf = 0 } })
            else
                trouble.close({ mode = "diagnostics", filter = { buf = 0 } })
            end
        end
        vim.keymap.set("n", "<C-6>", toggle_problems, { noremap = true })
        vim.keymap.set("n", "<leader>tt", toggle_problems, { noremap = true })
        vim.keymap.set("n", "[t", function()
            -- trouble._action("next")({ skip_groups = true, jump = true, mode = "diagnostics"    })
            trouble.next({ skip_groups = true, jump = true, mode = "diagnostics" })
        end, { noremap = true })
        vim.keymap.set("n", "]t", function()
            -- trouble._action("prev")({ skip_groups = true, jump = true, mode = "diagnostics" })
            trouble.prev({ skip_groups = true, jump = true, mode = "diagnostics" })
        end, { noremap = true })
      end,
    }
  },
})
folke commented 2 weeks ago

That has nothing to do with lazydev. Thats a limitation of luals

nickkadutskyi commented 2 weeks ago

Thanks, didn't realize that.