ms-jpq / coq_nvim

Fast as FUCK nvim completion. SQLite, concurrent scheduler, hundreds of hours of optimization.
GNU General Public License v3.0
3.54k stars 101 forks source link

Any tips on migrating to lazy.nvim? #549

Closed ristillu closed 1 year ago

ristillu commented 1 year ago

I have recently migrated from wbthomason/packer.nvim to folke/lazy.nvim. It has broken my coq. The use entry has changed and now looks like:

{
    "ms-jpq/coq_nvim",
    "branch = "coq",
    dependencies = { "ms-jpq/coq.artifacts", branch = "artifacts" },
    config = function() require("config.ms_jpq_coq") end,
    lazy = false,  -- ensure loaded
},

The only changes from packer are the syntax and the lazy = false, line to (I thought) ensure coq is loaded. coq works if I run :COQnow. But in my config/ms_jpq_coq.lua file that I'm loading I have

vim.g.coq_settings = {
    auto_start = true
}

local lsp = require("lspconfig")
local coq = require("coq")
-- set up servers below with ensure_capabilities etc

which is what I had with packer, except it is not auto-loading with lazy.

I've run with COQ_DEBUG=1 nvim $file -V10vimlog and there is nothing in the :LspLog or vimlog that seems obvious. Just nothing happens until I hit :COQnow. In the vimlog I can see that lazy processes the coq entry but it just doesn't load until I command it to. I also added print("loading coq") to the config/ms_jpq_coq.lua file to confirm that file is loaded, and it is.

Any tips?

ristillu commented 1 year ago

In answer to my own question, I figured out if I added auto_start to my init.lua it behaved as expected, therefore it was some weird ordering thing that lazy triggers.

To clean up my code, I removed the auto_start from my config for coq

--[[ vim.g.coq_settings = {
     auto_start = true
} ]]

local lsp = require("lspconfig")
local coq = require("coq")
-- set up servers below with ensure_capabilities etc

and changed the lazy entry to:

    {
        "ms-jpq/coq_nvim",
        branch = "coq",
        init = function() vim.g.coq_settings = { auto_start = true } end,
        dependencies = {
            { "ms-jpq/coq.artifacts", branch = "artifacts" },
            { "neovim/nvim-lspconfig" },
        },
        config = function() require("config.ms_jpq_coq") end,
        lazy = false,
    },

Note the added init line.

The init happens before the plugin is loaded, ref here. I guess the entry for the spec under the config part is where the behavior I noticed is implied:

config is executed when the plugin loads. The default implementation will automatically run require("plugin").setup(opts). "plugin" will default to name if specified, otherwise lazy.nvim will do its best to guess the correct plugin name. See also opts. To use the default implementation without opts set config to true.

NormTurtle commented 1 year ago

@ristillu im getting this error , but coq runs fine? image

NormTurtle commented 1 year ago

fixed tho

ZerdoX-x commented 1 year ago

@NormTurtle um... so... How did you fix this?