Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bug: Neoconf loads lspconfig for health check #31

Open
3 tasks done
CEbbinghaus opened this issue May 19, 2023 · 1 comment
Open
3 tasks done

bug: Neoconf loads lspconfig for health check #31

CEbbinghaus opened this issue May 19, 2023 · 1 comment
Labels
bug Something isn't working

Comments

@CEbbinghaus
Copy link

Did you check docs and existing issues?

  • I have read all the neoconf.nvim docs
  • I have searched the existing issues of neoconf.nvim
  • I have searched the existing issues of plugins related to this issue

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.

local ok, lsputil = pcall(require, "lspconfig.util")
if ok then
if #lsputil.available_servers() == 0 then
return true
else
util.error(
[[Setup `require("neoconf").setup()` should be run **BEFORE** setting up any lsp server with lspconfig]]
)
end
else

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 CEbbinghaus added the bug Something isn't working label May 19, 2023
@CEbbinghaus
Copy link
Author

A few possible solutions

  • Just not use neoconf to overwrite the options (my current temporary fix)
  • Don't initialize lspconfig in the config step (makes the code less clean)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant