Files
LazyVim-mirror/lua/lazyvim/plugins/extras/ai/copilot-chat.lua
Yiqian Liu 83468be350 fix(keymap): remove select mode remaps of printable characters (#6296)
## Description

Most of the "visual mode" mappings use "v" instead of "x", and therefore
also affect select mode.
If the key is a printable character, it is now unusable in select mode.
This is most prominent with `<leader>`, which is space by default, a
printable character.

The most common use of select mode is when it is automatically triggered
by snippets. Currently, trying to type space, g, <, >, etc. as the first
character of a snippet field will trigger their bind instead of actually
inserting the character.

I cannot currently think of any good reason why anyone would rely on
using select mode to execute any of these mapped actions.

## Checklist

- [x] I've read the
[CONTRIBUTING](https://github.com/LazyVim/LazyVim/blob/main/CONTRIBUTING.md)
guidelines.
2025-10-20 00:10:08 -07:00

112 lines
2.5 KiB
Lua

return {
{
"CopilotC-Nvim/CopilotChat.nvim",
branch = "main",
cmd = "CopilotChat",
opts = function()
local user = vim.env.USER or "User"
user = user:sub(1, 1):upper() .. user:sub(2)
return {
auto_insert_mode = true,
headers = {
user = "" .. user .. " ",
assistant = " Copilot ",
tool = "󰊳 Tool ",
},
window = {
width = 0.4,
},
}
end,
keys = {
{ "<c-s>", "<CR>", ft = "copilot-chat", desc = "Submit Prompt", remap = true },
{ "<leader>a", "", desc = "+ai", mode = { "n", "x" } },
{
"<leader>aa",
function()
return require("CopilotChat").toggle()
end,
desc = "Toggle (CopilotChat)",
mode = { "n", "x" },
},
{
"<leader>ax",
function()
return require("CopilotChat").reset()
end,
desc = "Clear (CopilotChat)",
mode = { "n", "x" },
},
{
"<leader>aq",
function()
vim.ui.input({
prompt = "Quick Chat: ",
}, function(input)
if input ~= "" then
require("CopilotChat").ask(input)
end
end)
end,
desc = "Quick Chat (CopilotChat)",
mode = { "n", "x" },
},
{
"<leader>ap",
function()
require("CopilotChat").select_prompt()
end,
desc = "Prompt Actions (CopilotChat)",
mode = { "n", "x" },
},
},
config = function(_, opts)
local chat = require("CopilotChat")
vim.api.nvim_create_autocmd("BufEnter", {
pattern = "copilot-chat",
callback = function()
vim.opt_local.relativenumber = false
vim.opt_local.number = false
end,
})
chat.setup(opts)
end,
},
-- Edgy integration
{
"folke/edgy.nvim",
optional = true,
opts = function(_, opts)
opts.right = opts.right or {}
table.insert(opts.right, {
ft = "copilot-chat",
title = "Copilot Chat",
size = { width = 50 },
})
end,
},
-- Blink integration
{
"saghen/blink.cmp",
optional = true,
---@module 'blink.cmp'
---@type blink.cmp.Config
opts = {
sources = {
providers = {
path = {
-- Path sources triggered by "/" interfere with CopilotChat commands
enabled = function()
return vim.bo.filetype ~= "copilot-chat"
end,
},
},
},
},
},
}