folke / neoconf.nvim

💼 Neovim plugin to manage global and project-local settings
Apache License 2.0
661 stars 27 forks source link

bug: Undefined field `lua_ls` #62

Closed heygarrett closed 42 minutes ago

heygarrett commented 3 weeks ago

Did you check docs and existing issues?

Neovim version (nvim -v)

NVIM v0.10.0
Build type: Release
LuaJIT 2.1.1716656478
Run "nvim -V1 -v" for more info

Operating system/version

macOS 14.5 (23F79)

Describe the bug

When using nvim-lspconfig to configure a language server, the language server name has an Undefined field warning (eg, in require("lspconfig").lua_ls.setup({}), lua_ls has warning "Undefined field lua_ls"). This happens with every language server I have configured.

Steps To Reproduce

  1. Have lua-language-server installed
  2. Use the included repro.lua to open the repro.lua in Neovim

Expected Behavior

The lua_ls in require("lspconfig").lua_ls.setup({}) will not have an Undefined field warning.

Repro

-- DO NOT change the paths and don't remove the colorscheme
local root = vim.fn.fnamemodify("./.repro", ":p")

-- set stdpaths to use .repro
for _, name in ipairs({ "config", "data", "state", "cache" }) do
    vim.env[("XDG_%s_HOME"):format(name:upper())] = root .. "/" .. name
end

-- bootstrap lazy
local lazypath = root .. "/plugins/lazy.nvim"
if not vim.loop.fs_stat(lazypath) then
    vim.fn.system({
        "git",
        "clone",
        "--filter=blob:none",
        "https://github.com/folke/lazy.nvim.git",
        lazypath,
    })
end
vim.opt.runtimepath:prepend(lazypath)

-- install plugins
local plugins = {
    "folke/tokyonight.nvim",
    "folke/neoconf.nvim",
    -- add any other plugins here
    {
        "https://github.com/neovim/nvim-lspconfig",
        config = function()
            require("neoconf").setup({})
            require("lspconfig").lua_ls.setup({})
        end,
    },
}
require("lazy").setup(plugins, {
    root = root .. "/plugins",
})

vim.cmd.colorscheme("tokyonight")
-- add anything else here
heygarrett commented 2 weeks ago

TIL nvim-lspconfig uses a metatable to set up the server configs:
https://github.com/neovim/nvim-lspconfig/blob/bd7c76375a511994c9ca8d69441f134dc10ae3bd/lua/lspconfig.lua#L36

So it looks like neoconf may just be revealing that they're not actually properties in the lspconfig table. Does that make this issue irrelevant? Let me know; I'm happy to close it.

folke commented 42 minutes ago

That has nothing to do with neoconf...