zbirenbaum / copilot.lua

Fully featured & enhanced replacement for copilot.vim complete with API for interacting with Github Copilot
MIT License
2.64k stars 75 forks source link

Can't `:Copilot auth` after loading a session #100

Closed D00mch closed 1 year ago

D00mch commented 1 year ago

When I open Neovim and run the :Copilot auth command, I see the output [Copilot] Authenticated as GitHub user: D00mch. I can still see the same output if I open a file with :e <path> after loading the session.

However, if I load a session with Neovim Session Manager and run the same command, I see the output [Copilot] Not running.

MunifTanjim commented 1 year ago

Looks like Neovim lost track of the LSP server that Copilot starts. You should probably ask about this problem on neovim-session-manager, since they'll have better idea why this might happen.

D00mch commented 1 year ago

One workaround I found is to have a keymap to setup Copilot after the session is loaded.

D00mch commented 1 year ago

The nvim-session-manager author proposed:

Hi! This could happen because we shutdown all LSP servers. You probably should ask copilot.lua to re-enable copilot after restarting LSP.

snowair commented 1 year ago

Yes, I agree that copilot.lua should give a function to restart the copilot LSP server. Because switch between projects meas the whole workspace and program language changed. Any LSP server must restart.

MunifTanjim commented 1 year ago

Can you try out https://github.com/zbirenbaum/copilot.lua/pull/112 and see if that solves the issue?

@D00mch @snowair

snowair commented 1 year ago

@MunifTanjim #112

    use {
        "zbirenbaum/copilot.lua",
        branch = "feat-smart-setup",
        cmd = "Copilot",
        after = "bufferline.nvim", 
        config = function()
            vim.defer_fn(function()
                require("copilot").setup()
            end, 100)
        end,
    }

Run: Copilot auth, get Client 5 quit with exit code 1 and signal 0

MunifTanjim commented 1 year ago

You shouldn't need vim.defer_fn. Can you try removing that?

snowair commented 1 year ago

You shouldn't need vim.defer_fn. Can you try removing that?

Yeah, I works now for any session.