Skip to content

Lazy loading copilot.lua causes error upon installation with lazy.nvim #436

Description

@dpetka2001

When lazy-loading copilot.lua with following configuration

return {
  {
    "zbirenbaum/copilot.lua",
    cmd = "Copilot",
    build = ":Copilot auth",
    event = "BufReadPost",
    -- commit = "784f4eb", -- good
    commit = "2cd99fb", -- bad
    opts = {},
  },
}

Then when the plugin is installed via lazy.nvim plugin manager, an error occurs [ERROR]: client is not initialized yet, which is caused by the part in the aforementioned config build = ":Copilot auth". The solution is to not include that. It seems that Copilot commands throw this error when the LSP server is not initialized, because I tried the same without the build part and upon installation, when I open Neovim and the dashboard appears, if I run manually :Copilot auth it also throws the error on the dashboard. A buffer has to be opened, so that the plugin loads first and LSP server attaches and then be able to run Copilot commands.

As you can see I have 2 commits in the above configuration, 2cd99fb which throws this error and 784f4eb which doesn't throw the error. So, this occurs because of some change in 2cd99fb commit.

Not sure if this is a bug per se, maybe it's intended behavior after commit 2cd99fb. I would just like some feedback regarding if this is a bug or not. I'm using LazyVim and build = ":Copilot auth" is present in the default configuration, which causes the error. But I was also able to repro the same error with just a plain lazy.nvim config, which contains the aforementioned plugin spec for Copilot.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions