jonahgoldwastaken / copilot-status.nvim

Simple Copilot status indicator for Neovim
MIT License
24 stars 0 forks source link

Lualine can't find `copilot_status` module. #1

Closed stankovictab closed 1 year ago

stankovictab commented 1 year ago

I'm getting this error that lualine can't find the copilot_status module, even though Copilot is loaded correctly, and lualine is loaded after copilot-status.

Error in packer_compiled: ...ctab/.config/nvim/lua/stankovictab/specifics/lualine.lua:27: module 'copilot_status' not found:^@^Ino field
 package.preload['copilot_status']^@^Ino file './copilot_status.lua'^@^Ino file '/usr/share/luajit-2.1.0-beta3/copilot_status.lua'^@^Ino
 file '/usr/local/share/lua/5.1/copilot_status.lua'^@^Ino file '/usr/local/share/lua/5.1/copilot_status/init.lua'^@^Ino file '/usr/share
/lua/5.1/copilot_status.lua'^@^Ino file '/usr/share/lua/5.1/copilot_status/init.lua'^@^Ino file '/home/stankovictab/.cache/nvim/packer_h
ererocks/2.1.0-beta3/share/lua/5.1/copilot_status.lua'^@^Ino file '/home/stankovictab/.cache/nvim/packer_hererocks/2.1.0-beta3/share/lua
/5.1/copilot_status/init.lua'^@^Ino file '/home/stankovictab/.cache/nvim/packer_hererocks/2.1.0-beta3/lib/luarocks/rocks-5.1/copilot_sta
tus.lua'^@^Ino file '/home/stankovictab/.cache/nvim/packer_hererocks/2.1.0-beta3/lib/luarocks/rocks-5.1/copilot_status/init.lua'^@^Ino f
ile './copilot_status.so'^@^Ino file '/usr/local/lib/lua/5.1/copilot_status.so'^@^Ino file '/usr/lib64/lua/5.1/copilot_status.so'^@^Ino
file '/usr/local/lib/lua/5.1/loadall.so'^@^Ino file '/home/stankovictab/.cache/nvim/packer_hererocks/2.1.0-beta3/lib/lua/5.1/copilot_sta
tus.so'
Please check your config for correctness

plugins.lua :

        -- Copilot is loaded above

    use {
        "jonahgoldwastaken/copilot-status.nvim",
        -- after = { "zbirenbaum/copilot.lua" },
        event = "BufReadPost",
        -- config = function()
        --  require('copilot_status').setup({
        --      icons = {
        --          idle = " ",
        --          error = " ",
        --          offline = " ",
        --          warning = "𥉉 ",
        --          loading = " ",
        --      },
        --      debug = false,
        --  })
        -- end
    }
    -- This needs to be after copilot-status, as it requires it to function
    use {
        'nvim-lualine/lualine.nvim', -- Way better status line than Airline
        -- after = {"jonahgoldwastaken/copilot-status.nvim"},
        config = "require('stankovictab.specifics.lualine')"
    }

lualine.lua :

...
    lualine_y = {require('copilot_status').status_string}, 
...
websmithcode commented 1 year ago

Same error

jonahgoldwastaken commented 1 year ago

Does the error persist when uncommenting this line?

-- after = {"jonahgoldwastaken/copilot-status.nvim"},
stankovictab commented 1 year ago

I think I've finally got it working, actually. The reason copilot-status wasn't being loaded into the module is because it obviously wasn't loaded by packer, and that is because my Copilot config (which copilot-status is dependant on) is set to load on cmd='Copilot', event='InsertEnter', in other words, Copilot would start only when I go into insert mode, and copilot-status doesn't like that because it needs to display the status as soon as you enter NeoVim, and because of that lualine crashes. So, I commented out the cmd and event keys from "zbirenbaum/copilot.lua", set the appropriate after keys for copilot-status and lualine, and it now works. It sucks a bit that Copilot will be loaded up every time on opening NeoVim, but hey. And it's also weird how if I try to set the after keys on either copilot-status or lualine, packer just goes crazy and crashes lualine with the above mentioned error. Really bizzare, don't know if that's a problem with packer itself. Anyway, here's the config.

    use {
        "zbirenbaum/copilot.lua",
        -- cmd = "Copilot",
        -- event = "InsertEnter", -- Copilot will be started only when entering insert mode
        config = function()
            -- ................ a lot of stuff here ..............
        end
    }

    use {
        'jonahgoldwastaken/copilot-status.nvim',
        -- after = { 'zbirenbaum/copilot.lua' },
        -- event = "BufReadPost",
        config = function()
            require('copilot_status').setup {
                icons = {
                    idle = " ",
                    error = " ",
                    offline = " ",
                    warning = "𥉉 ",
                    loading = " ",
                },
                debug = false,
            }
        end
    }

    use {
        'nvim-lualine/lualine.nvim', -- Way better status line than Airline
        -- after = { 'jonahgoldwastaken/copilot-status.nvim' },
        config = "require('stankovictab.specifics.lualine')"
    }

The lualine config file didn't change.

jonahgoldwastaken commented 1 year ago

@stankovictab I updated copilot-status to be more forgiving when copilot is not yet initialised (also checking if copilot is loaded on InsertEnter, for example). Let me know if your old configuration works with it and feel free to reopen the issue with further comments. :smile:

stankovictab commented 1 year ago

Seems to load better now, yeah, but packer still fails loading up lualine when I add after = { 'zbirenbaum/copilot.lua' } in copilot-status's packer config, so I'm still keeping that commented. However, I still don't think it's working as expected. For instance, when I open up a file the icon is in loading mode, which is good, but when I go into insert mode to type, and when Copilot activates and starts giving suggestions, the icon is still on loading mode. If I then open another buffer, the icon updates to the idle mode on both buffers. If instead of opening a new buffer I do :LspInfo, the icon changes to the offline mode, even though copilot still works. Don't ask me how I figured that one out, it's pure coincidence. I know this isn't related to this issue, it's just something I noticed.

jonahgoldwastaken commented 1 year ago

Maybe I should clarify this in the docs, but the status indicator is tied to the current buffer. If it's not attached to the buffer (as with :LspInfo) it's marked as offline, as there is no copilot client attached to the buffer. Maybe a "detached" icon would be better for this?

When the loading indicator seems "stuck", it's because copilot is still indicating it's loading suggestions. I don't augment any status, so whatever copilot gives me is displayed. Copilot does have the tendency to get stuck on loading when it can't find a proper suggestion I've realised, and can sometimes stay that way when you leave insert mode.