echasnovski / mini.nvim

Library of 40+ independent Lua modules improving overall Neovim (version 0.8 and higher) experience with minimal effort
MIT License
4.74k stars 179 forks source link

mini.deps example doesn't load LSP client in time #829

Closed bluebrown closed 4 months ago

bluebrown commented 4 months ago

Contributing guidelines

Module(s)

mini.deps

Description

There is an here, including lspconfig: https://github.com/echasnovski/mini.nvim/blob/e623d29561746637b49d30d6434338f88f44e856/scripts/init-deps-example.lua#L44

When following this, the first opened buffer won't get a LSP client attached. I think lspconfig should not be called later, to avoid this problem. It works as expected when using now to set up the LSP.

Neovim version

v0.10.0-dev-2954+g13ebfafc9

Steps to reproduce

later(function()
  add("neovim/nvim-lspconfig")
  local lspconfig = require("lspconfig")
  local caps = vim.lsp.protocol.make_client_capabilities()
  lspconfig["lua_ls"].setup({ capabilities = caps })
  lspconfig["gopls"].setup({ capabilities = caps })
end)

then run:

nvim init.lua # no client
:e main.go # has client

If you try the other way around, you see go doesnt have a client attached, but lua does.

Expected behavior

lsp client is attached to first buffer.

Actual behavior

lsp client is only attached from the second buffer onwards

It works when using it on now, but I am not sure if this is OK.

echasnovski commented 4 months ago

Thanks for pointing that out!

Yes, it indeed works like that. Mostly because I expected 'mini.nvim' to be used with 'mini.starter' (as I do right now) and later() leads to smaller startup time. But yeah, example 'init.lua' might be better off with now().

Should be fixed on latest main.