From 1ce1b1ee02c2aa06828934c10bb7fa2f88315fc8 Mon Sep 17 00:00:00 2001 From: jorgenwh Date: Sun, 9 Jun 2024 23:31:50 +0200 Subject: [PATCH] copilot disable/enable --- lua/plugins/copilot.lua | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/lua/plugins/copilot.lua b/lua/plugins/copilot.lua index 146c6607..1ba0d394 100644 --- a/lua/plugins/copilot.lua +++ b/lua/plugins/copilot.lua @@ -1,3 +1,17 @@ +local COPILOT_ENABLED = false + +vim.keymap.set('n', '', function() + if COPILOT_ENABLED then + vim.cmd 'Copilot disable' + COPILOT_ENABLED = false + print 'Copilot disabled' + else + vim.cmd 'Copilot enable' + COPILOT_ENABLED = true + print 'Copilot enabled' + end +end, { noremap = true, silent = true }) + return { 'zbirenbaum/copilot.lua', cmd = 'Copilot', @@ -6,8 +20,11 @@ return { local copilot = require 'copilot' local suggestion = require 'copilot.suggestion' + -- disable copilot by default copilot.setup { suggestion = { + enabled = COPILOT_ENABLED, + auto_trigger = true, keymap = { accept = '', next = '', @@ -28,7 +45,5 @@ return { -- Map to the global tab_complete function vim.api.nvim_set_keymap('i', '', 'v:lua.tab_complete()', { expr = true, noremap = true, silent = true }) - - suggestion.toggle_auto_trigger() end, }