I don't have coopilot, so you need to test it for yourself, but in general this is how I'm auto running commands in buffers with specific path.
In neovim you can use lua version of autocmd
. Bellow you have 2 of them.
One is to run :Copilot enable
in your ~/dev/
directory.
-- Force enable
vim.api.nvim_create_autocmd({ 'BufEnter' }, {
pattern = '/home/laurent/dev/*',
-- you could optionaly replace with
-- pattern = vim.fn.expand('~') .. '/dev/*',
command = "Copilot enable"
})
Second is optional. :Copilot disable
in place with your secrets.
-- Force disable
vim.api.nvim_create_autocmd({ 'BufEnter' }, {
pattern = '/home/laurent/private/*',
command = "Copilot disable"
})
edit:
@Laurent mentioned in the comment, a solution that will disable every buffer and then enable ~/dev/. Here is the code for it.
-- Force disable everywhere
vim.api.nvim_create_autocmd({ 'BufEnter' }, {
pattern = '*',
command = "Copilot disable"
})
-- Force enable ~/dev/*
vim.api.nvim_create_autocmd({ 'BufEnter' }, {
pattern = vim.fn.expand('~') .. '/dev/*',
command = "Copilot enable"
})