folke / neoconf.nvim

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

bug: Neoconf loads lspconfig for health check #31

Closed CEbbinghaus closed 4 months ago

CEbbinghaus commented 1 year ago

Did you check docs and existing issues?

Neovim version (nvim -v)

0.9.0

Operating system/version

Windows 11

Describe the bug

When neoconf is loaded it internally loads "lspconfig" to check if any servers are already active. https://github.com/folke/neoconf.nvim/blob/bbf98ce53481e6e8d6507de5a6f18d3264fb0df7/lua/neoconf/health.lua#L66-L75

This is fine if the only thing using neoconf are plugins that are also dependencies of lspconfig but when an external dependency (especially one that is loaded earlier than lspconfig) is ran it will cause neoconf to load lspconfig before it returns (which in this configuration loads a lsp server).

Steps To Reproduce

  1. have something earlier than lspconfig depend on neoconf
  2. run neovim and get

    Setup require("neoconf").setup() should be run BEFORE setting up any lsp server with lspconfig

Expected Behavior

Neoconf doesn't load lspconfig which creates the server but instead has some way of initializing without fetching the server count or solve it some other way that I haven't thought of

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",
    {
        'glepnir/dashboard-nvim',
        event = 'VimEnter',
        opts = function() return require 'neoconf'.get("plugins.dashboard", {}) end
    },
    {
        'neovim/nvim-lspconfig',
        config = function()
            local lspconfig = require 'lspconfig'
            lspconfig.lua_ls.setup {}
        end,
        event = "BufAdd",
        dependencies =
        {
            "folke/neoconf.nvim"
        }
    }
}
require("lazy").setup(plugins, {
  root = root .. "/plugins",
  defaults = {lazy = true}
})

vim.cmd.colorscheme("tokyonight")
-- add anything else here
CEbbinghaus commented 1 year ago

A few possible solutions

github-actions[bot] commented 4 months ago

This issue is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 7 days.

CEbbinghaus commented 4 months ago

oh I see you added stalebot, I will have to verify that this is still happening but this is still a relevant issue

folke commented 4 months ago

That has been fixed at some point

CEbbinghaus commented 4 months ago

Awesome. Thank you so much <3