zbirenbaum / copilot-cmp

Lua plugin to turn github copilot into a cmp source
MIT License
1.08k stars 39 forks source link

module 'copilot_cmp.comparators' not found #43

Closed technicalpickles closed 1 year ago

technicalpickles commented 1 year ago

I'm trying the snippet suggested in https://github.com/zbirenbaum/copilot-cmp#comparators

cmp.setup {
  ...
  sorting = {
    priority_weight = 2,
    comparators = {
      require("copilot_cmp.comparators").prioritize,
      require("copilot_cmp.comparators").score,

And get this:

Error detected while processing /Users/josh.nichols/workspace/pickled-nvim/init.lua:
E5113: Error while calling lua chunk: ...chols/.config/nvim/lua/pickled-nvim/language-support.lua:144: module 'copilot_cmp.comparators' not found:
        no field package.preload['copilot_cmp.comparators']
        no file './copilot_cmp/comparators.lua'
        no file '/opt/homebrew/share/luajit-2.1.0-beta3/copilot_cmp/comparators.lua'
        no file '/usr/local/share/lua/5.1/copilot_cmp/comparators.lua'
        no file '/usr/local/share/lua/5.1/copilot_cmp/comparators/init.lua'
        no file '/opt/homebrew/share/lua/5.1/copilot_cmp/comparators.lua'
        no file '/opt/homebrew/share/lua/5.1/copilot_cmp/comparators/init.lua'
        no file './copilot_cmp/comparators.so'
        no file '/usr/local/lib/lua/5.1/copilot_cmp/comparators.so'
        no file '/opt/homebrew/lib/lua/5.1/copilot_cmp/comparators.so'
        no file '/usr/local/lib/lua/5.1/loadall.so'
        no file './copilot_cmp.so'
        no file '/usr/local/lib/lua/5.1/copilot_cmp.so'
        no file '/opt/homebrew/lib/lua/5.1/copilot_cmp.so'
        no file '/usr/local/lib/lua/5.1/loadall.so'
stack traceback:
        [C]: in function 'require'
        ...chols/.config/nvim/lua/pickled-nvim/language-support.lua:144: in main chunk
        [C]: in function 'require'
        /Users/josh.nichols/workspace/pickled-nvim/init.lua:25: in main chunk

I wonder if it has to do with using a vim.defer_fn for copilot.lua and `after = { 'copilot.lua'} for copilot-cmp?

    use {
        'zbirenbaum/copilot.lua',
        event = 'VimEnter',
        config = function()
            vim.defer_fn(function()
                require("copilot").setup({
                    ft_disable = vim.g.filetype_plugin_config.copilot.disable,

                    -- suggested to disable these when using with cmp
                    suggestion = { enabled = false },
                    panel = { enabled = false },
                })
            end, 100)
        end,
    }

    use {
        'zbirenbaum/copilot-cmp',
        after = {'copilot.lua'},
        config = function ()
            require("copilot_cmp").setup {
                method = "getCompletionsCycling",
                formatters = {
                    label = require("copilot_cmp.format").format_label_text,
                    insert_text = require("copilot_cmp.format").format_insert_text,
                    preview = require("copilot_cmp.format").deindent,
                },
            }
        end
    }

my config for reference: https://github.com/technicalpickles/pickled-nvim

dongdongbh commented 1 year ago

Encontering same problem, by remove after = {'copilot.lua'} to make it work.

technicalpickles commented 1 year ago

I think that is what I did too. I since moved from packer to lazy.nvim so can't confirm for sure.

chikko80 commented 1 year ago

@technicalpickles i am also on lazy.nvim and can't get it to work. Whats your setup on lazy.nvim?