cpow / neovim-for-newbs

a simple lua neovim configuration for newbs
451 stars 81 forks source link

copilot #3

Open jmandel1027 opened 6 months ago

jmandel1027 commented 6 months ago

Hey dude!

Love these tutorials, I went from "wtf eww lua" to "this is the way" I've been pushing myself to learn tmux and nvim for a while now, I had been fussing about with vimscript and pathogen but have since converted over.

Would love to see a copilot tutorial, I've been struggling with getting both github/copilot.vim and zbirenbaum/copilot.lua going. I suspect it has to do with the keymappings with cmp and im probably doing something really dumb lol. I think thats the last missing piece for me thats preventing me from leaving vscode behind as my main driver

andresgutgon commented 6 months ago

I have this in plugins/copilot.lua

return {
  {
    "github/copilot.vim",
    config = function()
      vim.g['copilot_assume_mapped '] = true
      vim.g['copilot_no_tab_map'] = true
      vim.g['copilot_tab_fallback '] = ""
    end
  }
}
patrick91 commented 6 months ago

for me the basic configuration just works

return {
    {
        "github/copilot.vim",
    },
}

and make sure to run :Copilot setup :)

jmandel1027 commented 6 months ago

Happy new year! thanks for circling back here.

I was able to get the copilot suggestions plugged in, but I'm still having trouble with the autocompletion and such. For some reason my bindings aren't allowing me to browse the suggestions and such or accept changes, I've tried a few things like listing imap and nmap bindings but still wrangling it on my end. probably just a noob issue and need to find out what keymaps/mode allow for access to that menu.

https://github.com/jmandel1027/dotfiles/blob/main/nvim/lua/plugins/completion.lua

cjoke commented 5 months ago

First I will thanks for all the youtube series and this repo! In addition to this configuration I also have installed copilot and copilotchat https://github.com/cjoke/neovim-for-cjoke/blob/main/lua/plugins/copilotchat.lua . Its a basic installation where I just have a :vsplit and the dialog goes through commandline :CopilotChat say what you want here, and you get the respond in a new buffer (that I chose to have in another window (vsplit) .

in copilot.lua I have

return {
  {
    "github/copilot.vim",
      config = function()
        vim.keymap.set('i', '<C-l>', 'copilot#Accept("<CR>")', {
          expr = true,
          replace_keycodes = false
        })
        vim.keymap.set('i', '<C-h>', '<Plug>(copilot-dismiss)')
        vim.keymap.set('i', '<C-k>', '<Plug>(copilot-next)')
        vim.keymap.set('i', '<C-j>', '<Plug>(copilot-previous)')
        vim.keymap.set('i', '<C-L>', '<Plug>(copilot-accept-word)')
        vim.g.copilot_no_tab_map = true
    end,
  },
}

and in vim-options.lua I have

-- Set up copilot config
vim.g.copilot_no_tab_maps = true
vim.g.copilot_disable_mappings = 1
vim.g.copilot_filetypes = {
    ["*"] = false,
    ["python"] = true,
    ["c"] = true,
    ["cpp"] = true,
  -- ["lua"] = true,
  -- markdown is needed for CopilotChat
  ["Markdown"] = true,
}
kjvdven commented 4 months ago

There is also the alternative plugin

"zbirenbaum/copilot.lua"

This one is used in the Lazy distribution