Giter Club home page Giter Club logo

Comments (17)

Shougo avatar Shougo commented on July 17, 2024

Neither adding neoconf as a dependency of lspconfig, nor adding very high priority to it, helps.

Well, I think the dependency should work.
You should upload the config.

from lazy.nvim.

sarmong avatar sarmong commented on July 17, 2024

Here's the minimal config.

I should also note that LazyVim has cyclic dependency for these packages (I don't know why)
https://github.com/LazyVim/LazyVim/blob/f086bcde253c29be9a2b9c90b413a516f5d5a3b2/lua/lazyvim/plugins/lsp/init.lua#L4-L7

But, more importantly, calls neoconf.setup in lspconfig's config function
https://github.com/LazyVim/LazyVim/blob/f086bcde253c29be9a2b9c90b413a516f5d5a3b2/lua/lazyvim/plugins/lsp/init.lua#L96-L100

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",
    "--single-branch",
    "https://github.com/folke/lazy.nvim.git",
    lazypath,
  })
end
vim.opt.runtimepath:prepend(lazypath)

-- install plugins
local plugins = {
  -- do not remove the colorscheme!
  "folke/tokyonight.nvim",
  -- add any other pugins here
  {
    "folke/neoconf.nvim",
    priority = 50000,
    config = function()
      require("neoconf").setup()
      print("Finished setting up neoconf")
    end,
  },
  {
    "neovim/nvim-lspconfig",
    dependencies = {
      "folke/neoconf.nvim",
    },
    config = function()
      require("lspconfig").tsserver.setup({})
      print("Finished setting up lspconfig")
    end,
  },
}
require("lazy").setup(plugins, {
  root = root .. "/plugins",
})

-- add anything else here
vim.opt.termguicolors = true
-- do not remove the colorscheme!
vim.cmd([[colorscheme tokyonight]])

from lazy.nvim.

Shougo avatar Shougo commented on July 17, 2024

The dependency seems wrong.

neoconfig depends on nvim-lspconfig, but nvim-lspconfig does not depend on neoconfig.

  {
    "folke/neoconf.nvim",
    priority = 50000,
    dependencies = {
      "neovim/nvim-lspconfig",
    },
    config = function()
      require("neoconf").setup()
      print("Finished setting up neoconf")
    end,
  },
  {
    "neovim/nvim-lspconfig",
    config = function()
      require("lspconfig").tsserver.setup({})
      print("Finished setting up lspconfig")
    end,
  },

from lazy.nvim.

Shougo avatar Shougo commented on July 17, 2024

I should also note that LazyVim has cyclic dependency for these packages (I don't know why)
https://github.com/LazyVim/LazyVim/blob/f086bcde253c29be9a2b9c90b413a516f5d5a3b2/lua/lazyvim/plugins/lsp/init.lua#L4-L7

Hm.. I don't know why.

from lazy.nvim.

sarmong avatar sarmong commented on July 17, 2024

The dependency seems wrong.

Technically, you are right. This is how it is supposed to be.

However:

  1. Neoconf depends on lspconfig.utils, it doesn't depend on servers being set up.
  2. Quite the contrary, it depends on servers not being set up when it is being set up.
  3. The config you sent causes lspconfig.config to be called before neoconf.config, which causes error.
    image

from lazy.nvim.

Shougo avatar Shougo commented on July 17, 2024

Hm...
If so you need to call lspconfig setup in neoconf config.
It is ugly though.

from lazy.nvim.

sarmong avatar sarmong commented on July 17, 2024

Or call neoconf setup in lspconfig config.

Both are ugly, that's why I opened the issue.

from lazy.nvim.

dpetka2001 avatar dpetka2001 commented on July 17, 2024

I don't think that's possible, since when you require("lspconfig.util") module, the lspconfig plugin will be loaded and thus its config function will also execute. So, it makes sense to call neoconf setup in the lspconfig config function to keep the correct order of loading. Otherwise, neoconf should be changed to not require("lspconfig.util") and implement some internal solution, in which case this isn't really lazy's problem.

PS: relevant piece in the docs

This means that if you have a plugin A that is lazy-loaded and a plugin B that requires a module of plugin A, then plugin A will be loaded on demand as expected.

from lazy.nvim.

Shougo avatar Shougo commented on July 17, 2024

@sarmong Yes. It is LazyVim solution.

from lazy.nvim.

sarmong avatar sarmong commented on July 17, 2024

@dpetka2001

if you have a plugin A that is lazy-loaded

Neither one is lazy-loaded in my example.

In my opinion there need to be a behavior to prevent a module from loading like in this example. Either with priority or in some other way.

from lazy.nvim.

dpetka2001 avatar dpetka2001 commented on July 17, 2024

It doesn't matter if it's lazy-loaded or not. The point is that when you require a module from another plugin, that plugin will be loaded.

from lazy.nvim.

dpetka2001 avatar dpetka2001 commented on July 17, 2024

I think you could also do

	{
		"neovim/nvim-lspconfig",
		dependencies = {
			{
				"folke/neoconf.nvim",
				config = function()
					require("neoconf").setup()
					print("Finished setting up neoconf")
				end,
			},
		},
		config = function()
			require("lspconfig").tsserver.setup({})
			print("Finished setting up lspconfig")
		end,
	},

This also should load neoconf first and there's no need for priority. Also keeps the 2 config functions separate.

from lazy.nvim.

sarmong avatar sarmong commented on July 17, 2024

@dpetka2001

This indeed works, thanks.

However here is a weird part. In the config below, without priority it works as it should (neoconf, then lspconfig), but if I set priority, then suddenly lspconfig finishes before neoconf

  {
    "folke/neoconf.nvim",
    -- priority = 50000,
    config = function()
      require("neoconf").setup()
      print("Finished setting up neoconf")
    end,
  },
  {
    "neovim/nvim-lspconfig",
    dependencies = { "folke/neoconf.nvim" },
    config = function()
      require("lspconfig").tsserver.setup({})
      print("Finished setting up lspconfig")
    end,
  },

from lazy.nvim.

sarmong avatar sarmong commented on July 17, 2024

Actually, I think I might be wrong. With the config above (without priority set) the order seems to be random.

from lazy.nvim.

sarmong avatar sarmong commented on July 17, 2024

If I set priority on lspconfig instead, then neoconf always loads first...

Even though it is now consistent, this is some weird implicit behaviour that shouldn't be happening.

from lazy.nvim.

dpetka2001 avatar dpetka2001 commented on July 17, 2024

priority is only run on start plugins. I believe that since neoconf is declared as a dependency for lspconfig it's not considered a start plugin. Just do :=require("lazy.core.config").plugins and observe the loaded field for neoconf compared to the loaded field for lspconfig.

PS: I don't think it's inconsistent behavior. I believe it works as intended, but we're just not understanding how lazy.nvim operates in depth.

from lazy.nvim.

dpetka2001 avatar dpetka2001 commented on July 17, 2024

If I set priority on lspconfig instead, then neoconf always loads first...

This happens because lspconfig will be loaded first with the highest priority and then it itself has neoconf as dependency, which means that neoconf will be required first before lspconfig loading finishes. I think the priority and the sorting of start plugins happens during the lazy.nvim parsing the specs phase.

So to ensure that neoconf will finish first, you have to either require it inside the lspconfig config function or include the whole spec of neoconf inside lspconfig dependencies, which also keeps the 2 config functions separate.

from lazy.nvim.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.