If you’re using copilot and by luck also use pass to manage your passwords, you will find that the default configuration, or rather the configuration where you want copilot enabled everywhere, basically creates a risk for your precious passwords… As Copilot will be enabled by default, on text files.

My dataaa!

So here’s the snippet I use:

-- initialize copilot
local copilot = {
  "zbirenbaum/copilot.lua",
  "ofseed/copilot-status.nvim",
  cmd = "Copilot",
  build = ":Copilot auth",
  event = "InsertEnter",
  opts = {
    filetypes = {
      sh = function()
        if string.match(vim.fs.basename(vim.api.nvim_buf_get_name(0)), "^%.env.*") then
          -- disable for .env files
          return false
        end
        return true
      end,
      text = function()
        if
          vim.has_key(vim.environ(), "GIT_CEILING_DIRECTORIES") or vim.has_key(vim.environ(), "PASS_VERSION")
        then
          -- disable for .env files
          return false
        end
        return true
      end,
    },
  },
}

I should eventually add this too to my dotfiles… Once I have the time to do so.

My dotfiles would be here, if I updated them