astro-nvim-v3 - Note: disable tab when using copilot
This commit is contained in:
@@ -1,33 +1,50 @@
|
||||
return {
|
||||
"okuuva/auto-save.nvim",
|
||||
cmd = "ASToggle", -- optional for lazy loading on command
|
||||
event = { "InsertLeave", "TextChanged" }, -- optional for lazy loading on trigger events
|
||||
lazy = true,
|
||||
opts = {
|
||||
-- your config goes here
|
||||
-- or just leave it empty :)
|
||||
enabled = true, -- start auto-save when the plugin is loaded (i.e. when your package manager loads it)
|
||||
trigger_events = { -- See :h events
|
||||
immediate_save = { "BufLeave", "FocusLost" }, -- vim events that trigger an immediate save
|
||||
defer_save = {"TextChanged" }, -- vim events that trigger a deferred save (saves after `debounce_delay`)
|
||||
cancel_deferred_save = { "InsertEnter" }, -- vim events that cancel a pending deferred save
|
||||
},
|
||||
-- function that takes the buffer handle and determines whether to save the current buffer or not
|
||||
-- return true: if buffer is ok to be saved
|
||||
-- return false: if it's not ok to be saved
|
||||
-- if set to `nil` then no specific condition is applied
|
||||
--
|
||||
condition = function(buf)
|
||||
-- Check if vim-visual-multi is active
|
||||
local visual_multi_active = vim.g.VM_is_active or false
|
||||
if visual_multi_active then return false end
|
||||
-- Additional conditions can be added here if needed
|
||||
return true
|
||||
end,
|
||||
event = { "User AstroFile", "InsertEnter" },
|
||||
dependencies = {
|
||||
"AstroNvim/astrocore",
|
||||
opts = {
|
||||
autocmds = {
|
||||
autoformat_toggle = {
|
||||
-- Disable autoformat before saving
|
||||
{
|
||||
event = "User",
|
||||
desc = "Disable autoformat before saving",
|
||||
pattern = "AutoSaveWritePre",
|
||||
callback = function()
|
||||
-- Save global autoformat status
|
||||
vim.g.OLD_AUTOFORMAT = vim.g.autoformat
|
||||
vim.g.autoformat = false
|
||||
|
||||
write_all_buffers = false, -- write all buffers when the current one meets `condition`
|
||||
noautocmd = false, -- do not execute autocmds when saving
|
||||
lockmarks = false, -- lock marks when saving, see `:h lockmarks` for more details
|
||||
debounce_delay = 10000, -- delay after which a pending save is executed
|
||||
local old_autoformat_buffers = {}
|
||||
-- Disable all manually enabled buffers
|
||||
for _, bufnr in ipairs(vim.api.nvim_list_bufs()) do
|
||||
if vim.b[bufnr].autoformat then
|
||||
table.insert(old_autoformat_buffers, bufnr)
|
||||
vim.b[bufnr].autoformat = false
|
||||
end
|
||||
end
|
||||
|
||||
vim.g.OLD_AUTOFORMAT_BUFFERS = old_autoformat_buffers
|
||||
end,
|
||||
},
|
||||
-- Re-enable autoformat after saving
|
||||
{
|
||||
event = "User",
|
||||
desc = "Re-enable autoformat after saving",
|
||||
pattern = "AutoSaveWritePost",
|
||||
callback = function()
|
||||
-- Restore global autoformat status
|
||||
vim.g.autoformat = vim.g.OLD_AUTOFORMAT
|
||||
-- Re-enable all manually enabled buffers
|
||||
for _, bufnr in ipairs(vim.g.OLD_AUTOFORMAT_BUFFERS or {}) do
|
||||
vim.b[bufnr].autoformat = true
|
||||
end
|
||||
end,
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
opts = {},
|
||||
}
|
||||
|
||||
@@ -93,9 +93,12 @@ return {
|
||||
-- Esc to close completion menu
|
||||
["<Esc>"] = cmp.mapping { i = cmp.mapping.abort(), c = cmp.mapping.close() },
|
||||
|
||||
|
||||
-- Tab to select completion
|
||||
["<Tab>"] = cmp.mapping(function(fallback)
|
||||
if cmp.visible() and has_words_before() then
|
||||
|
||||
vim.g.copilot_no_tab_map = true -- NOTE: disable copilot's tab mapping PART1
|
||||
fallback()
|
||||
else
|
||||
fallback()
|
||||
@@ -118,8 +121,9 @@ return {
|
||||
end
|
||||
end, { "i", "s" }),
|
||||
|
||||
-- NOTE: disable tabl when using copilot PART2
|
||||
vim.api.nvim_set_keymap("i", "<C-f>", 'copilot#Accept("\\<CR>")', { expr = true, silent = true }),
|
||||
-- vim.g.copilot_no_tab_map = true,
|
||||
vim.keymap.del("i", "<Tab>"),
|
||||
-- ["<C-f>"] = cmp.mapping(function(fallback)
|
||||
-- -- Check if Copilot is suggesting something
|
||||
-- if vim.fn["copilot#Accept"]() ~= "" then
|
||||
@@ -130,6 +134,7 @@ return {
|
||||
},
|
||||
experimental = {
|
||||
ghost_text = false, -- this feature conflict with copilot.vim's preview.
|
||||
|
||||
},
|
||||
})
|
||||
end,
|
||||
|
||||
@@ -23,8 +23,7 @@ return {
|
||||
{ "CRAG666/code_runner.nvim", enabled = false },
|
||||
{ "RRethy/vim-illuminate", enabled = false },
|
||||
{ "OXY2DEV/markview.nvim", enabled = false },
|
||||
|
||||
-- { "kevinhwang91/nvim-ufo", enabled = false },
|
||||
{ "kevinhwang91/nvim-ufo", enabled = false },
|
||||
|
||||
-- interface
|
||||
-- { "HiPhish/rainbow-delimiters.nvim", enabled = true },
|
||||
|
||||
Reference in New Issue
Block a user