-
Notifications
You must be signed in to change notification settings - Fork 119
Feature Request: Disabled by Default? #302
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Try: return {
{
"zbirenbaum/copilot.lua",
opts = {
filetypes = {
["."] = false,
go = true
},
},
},
}
|
Unfortunately, does not seem to change the behavior @nounderline. |
+1 to this. I expected the I can enable it using |
I agree that an option like that is needed, copilot is for many people something that should be opt in and not opt out, using A workaround is just to have |
+1 It would be great to have a way for disabling copilot by default. I share my neovim between different devices with and without copilot access. Thus it pops up on every completion request to login to copilot, which initially let me drop the plugin. Edit found the issue on my side. For loading it only on certain devices, I wrote the following code to just include the my config module based on the hostname. local function get_hostname()
local f = io.popen ("/bin/hostname")
local hostname = f:read("*a") or ""
f:close()
hostname =string.gsub(hostname, "\n$", "")
return hostname
end
if get_hostname() == "HOSTNAME_WITH_COPILOT" then
require "config.general.copilot"
end |
see my setup that is losely based on what I used to have with supermaven and since then moved (can't get supermaven to work as source for blink) plugin via plugins/copilot.lua M = {
"zbirenbaum/copilot.lua",
cmd = "Copilot",
event = "InsertEnter",
config = function()
-- only setup if global state control value is set ( and it's not by default )
-- just an extra ensure check as setup is meant to only be called by toggling func
local is_off = vim.g.copilot_enabled
if not is_off then
-- setup own false augroup to prevent inbuilt teardown from erroring out due to lack
-- of internally set up augroup
-- (setup's not been called yet. We are killing it right away in the womb xd)
vim.api.nvim_create_augroup("copilot.client", { clear = true })
-- wrap things down forcefully using inbuilt client function
require("copilot.client").teardown()
else
local copilot = require("copilot")
copilot.setup({
suggestions = { enabled = false },
panel = { enabled = false },
})
end
end,
}
return M setup toggling command in my user_commands.lua -- custom toggle for AI
local toggleCopilot = function()
local copilot = require("copilot")
local client = require("copilot.client")
-- toggle global variable for stop condition
-- first toggle sets the none existing variable to true
vim.g.copilot_enabled = not vim.g.copilot_enabled
-- stop or start copilot
local noti = require("notify")
local noti_opts = { title = "Copilot", icon = "", timeout = 1000, hide_from_history = true }
if vim.g.copilot_enabled then
-- spin up lsp from scratch ang get client setup and attached
copilot.setup()
client.setup()
noti("ON", "info", noti_opts)
else
-- detatch first to prevent lsp spamming it's own notifications when teardown is called
client.buf_detach()
-- destroy microsoft XD
client.teardown()
noti("OFF", "error", noti_opts)
end
end
api.nvim_create_user_command("ToggleCopilot", toggleCopilot, { range = false }) then we just set up a binding as we need local map = vim.keymap.set
-- AI
map("n", "<leader>S", "<cmd>ToggleCopilot<cr>", { desc = " Toggle Copilot" }) |
Is the goal to simply not have the suggestions? If you are looking to minimize the startup time then I could submit a PR with the option to have it 'enabled manually only', as right now it is enabled upon loading. Though @zbirenbaum might lose it if I create yet another PR 😂😭 |
This setup of mine works fine with LazyVim. lua/config/options.lua: vim.g.copilot_enabled = false -- sets the default lua/plugins/copilot.lua: return {
"zbirenbaum/copilot.lua",
cmd = "Copilot",
build = ":Copilot auth",
config = function()
Snacks.toggle({
name = "Github Copilot",
get = function()
if not vim.g.copilot_enabled then -- HACK: since it's disabled by default the below will throw error
return false
end
return not require("copilot.client").is_disabled()
end,
set = function(state)
if state then
require("copilot").setup() -- setting up for the very first time
require("copilot.command").enable()
vim.g.copilot_enabled = true
else
require("copilot.command").disable()
vim.g.copilot_enabled = false
end
end,
}):map("<leader>ux")
end,
} |
I'm using copilot.lua and copilot-cmp.lua and find the workflow great, but prefer to start my sessions with copilot disabled, then enable it when desired/needed. Could there be an option added to change the initialized state from enabled to disabled?
The text was updated successfully, but these errors were encountered: