zbirenbaum / copilot.lua

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

nil value on 'plugin_path' #15

Closed opakholis closed 2 years ago

opakholis commented 2 years ago

im using LunarVim + nvim head branch, and get this message error at startup

Error executing vim.schedule lua callback: ...im/site/pack/packer/opt/copilot.lua/lua/copilot/util.lua:56: attempt to concatenate local 'plugin_path' (a nil value)
stack traceback:
        ...im/site/pack/packer/opt/copilot.lua/lua/copilot/util.lua:56: in function 'get_copilot_path'
        ...k/packer/opt/copilot.lua/lua/copilot/copilot_handler.lua:9: in function 'start'
        [string "..."]: in function ''
        vim/_editor.lua: in function ''
        vim/_editor.lua: in function <vim/_editor.lua:0>

so i replace my config following this solution because LunarVim things 😆, but still getting the same error message

  {
    "zbirenbaum/copilot.lua",
    event = "InsertEnter",
    config = function()
      vim.schedule(function
-        require("copilot").setup()
+       require("copilot.copilot_handler").start(vim.fn.expand "$HOME" .. "/.local/share/lunarvim/")
      end)
    end,
  },
opakholis commented 2 years ago

the output of nvim -v

NVIM v0.7.0-dev+1416-g012c05580
Build type: Release
LuaJIT 2.1.0-beta3
Compiled by opxop@local

Features: +acl +iconv +tui
See ":help feature-compile"

   system vimrc file: "$VIM/sysinit.vim"
  fall-back for $VIM: "/usr/local/share/nvim"

Run :checkhealth for more info
zbirenbaum commented 2 years ago

Try this:

use {
    "zbirenbaum/copilot.lua",
    event = "InsertEnter",
    config = function()
      vim.schedule(function
        require("copilot.copilot_handler").start({ plugin_manager_path = vim.fn.expand "$HOME" .. "/.local/share/lunarvim/" })
      end)
    end,
 },
zbirenbaum commented 2 years ago

The reason this popped up is because there's more than one config option now, so it needs to be specified.

opakholis commented 2 years ago

i dont really understand, sorry. now another message pops up image

opakholis commented 2 years ago

if i add site/pack/packer/ like so

require("copilot.copilot_handler").start {
  -- plugin_manager_path = vim.fn.expand "$HOME" .. "/.local/share/lunarvim/",
  plugin_manager_path = vim.fn.expand "$HOME" .. "/.local/share/lunarvim/site/pack/packer",
}

the error message popped up when I entered insert mode

image

zbirenbaum commented 2 years ago

if i add site/pack/packer/ like so

require("copilot.copilot_handler").start {
  -- plugin_manager_path = vim.fn.expand "$HOME" .. "/.local/share/lunarvim/",
  plugin_manager_path = vim.fn.expand "$HOME" .. "/.local/share/lunarvim/site/pack/packer",
}

the error message popped up when I entered insert mode

image

Sorry, for the delay, I didn't notice you responded and github didn't send a notification for some reason. The config handler was doing some really weird stuff. I deleted everything and rewrote it properly. I tested out that snippet but with my own path and its working fine now. Don't call copilot_handler.start directly, thats where the on_attach error came from. That was a a workaround before I wrote a real setup function.

Just do this in your packer use:

use  {
    "zbirenbaum/copilot.lua",
    event = {"InsertEnter"},
    config = function()
      vim.schedule(function()
        require("copilot").setup({
           plugin_manager_path = vim.fn.expand "$HOME" .. "/.local/share/lunarvim/site/pack/packer",
        })
      end)
    end,
},
opakholis commented 2 years ago

that's working now, thanks for your help @zbirenbaum