zbirenbaum / copilot.lua

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

Copilot stays disabled for yaml and markdown file types #304

Open udmehrot opened 2 months ago

udmehrot commented 2 months ago

Enabled copilot for Markdown and Yaml with following -

   1   │ return {
   2   │   "zbirenbaum/copilot.lua",
   3   │   cmd = "Copilot",
   4   │   event = "InsertEnter",
   5   │   config = function()
   6   │     require("copilot").setup({
   7   │       suggestion = { enabled = false },
   8   │       panel = { enabled = false },
   9   │       filetypes = {
  10   │         yaml = true,
  11   │         markdown = true,
  12   │       },
  13   │     })
  14   │   end,
  15   │ }

Exit out of nvim and enter again.

Open a yaml file. Copilot is not loaded.

Open a JSON file and Copilot is loaded.

Switch to YAML file buffer and run :Copilot status. I get the following error - [Copilot] Disabled ('filetype' yaml rejected by internal_filetypes[yaml])

udmehrot commented 2 months ago

I tried to add ["*"] = true to filtypes in my plugins filetypes configuration to no avail.

Adding following to init.lua does not work either.

-- Enable copilot filetypes
vim.g.copilot_filetypes = {
  "yaml",
  "yml",
  "markdown",
}

A point to note, I had installed gihub/copilot.vim before installing this plugin. I am wondering if there is lingering config from that plugin that is preventing me from overriding defaults.

Any help with be appreciated.

antonkesy commented 2 months ago

I tried the example config from the projects README and it kinda works.

Using only ["."] = true, does not work for markdown, but explicitly adding markdown = true, does. BUT It did not automatically start Copilot inside the markdown buffer (other buffers like make, C++, Python worked without any issue). I had to run Copilot enable manually.

Hope this helps. Here is my config as reference:

  {
    "zbirenbaum/copilot.lua",
    cmd = "Copilot",
    event = "InsertEnter",
    config = function()
      require("copilot").setup({
        suggestion = {
          enabled = true,
          auto_trigger = true,
          keymap = {
            accept = "<M-y>",
            accept_word = false,
            accept_line = false,
            next = "<M-l>",
            prev = "<M-h>",
            dismiss = "<C-]>",
          },
        },
        filetypes = {
          yaml = true,
          markdown = true,
          help = true,
          gitcommit = true,
          gitrebase = true,
          hgcommit = true,
          svn = true,
          cvs = false,
          ["."] = true,
        }
      })
    end,
  }