Files
lua-nvim/lua/cargdev/plugins/copilot.lua
Carlos Gutierrez 06dbe4d892 chore: remove local/unused plugins and refactor core configs
- Remove locally-developed or rarely-used plugin packages (codetyper, curls, edgy, flash) to reduce maintenance surface, external deps, and startup cost; these were local/optional and caused complexity.
- Clean up stale/keymap docs and small duplicate or experimental files (keymaps/README.md, sudoku keymaps).
- Apply targeted refactors to core modules for readability, robustness, and to align Java/DAP/Copilot integrations with local environment.
- Removed plugin modules:
  - lua/cargdev/plugins/codetyper.lua (deleted)
  - lua/cargdev/plugins/curls.lua (deleted)
  - lua/cargdev/plugins/edgy.lua (deleted)
  - lua/cargdev/plugins/flash.lua (deleted)
  - Added .codetyper to .gitignore
- Java / JDTLS:
  - ftplugin/java.lua: pin jdtls java executable to JDK 25, switch to mac_arm config, enable LSP formatter and declare multiple runtimes (JavaSE-17, JavaSE-25).
- Notifications & startup UX:
  - lua/cargdev/core/function/notification_manager.lua: large refactor — use local aliases (api, cmd, loop, opt), improved docs, dashboard-aware handling, nvim-notify fallback, safer tracking and cleanup of notifications.
- Utilities & monitors:
  - lua/cargdev/core/function/performance_monitor.lua: use local references, better notify usage and docs.
  - lua/cargdev/core/function/project_commands.lua: add docs, use local api/fn/notify, clearer RunProject/DebugProject commands.
- Terminal helper:
  - lua/cargdev/core/function/openTerminal.lua: add module docs and small refactor to use local cmd/api aliases and expose keymap.
- Keymaps & docs:
  - Removed stale keymaps README (lua/cargdev/core/keymaps/README.md).
  - Reworked many keymap files: docstrings, renamed/moved mappings to avoid conflicts, moved DAP mappings into dap plugin config, removed/disabled experimental mappings (see files under lua/cargdev/core/keymaps/*).
  - Adjusted quick keybindings and prefixes to reduce overlaps.
- Plugins & integrations:
  - lua/cargdev/plugins/formatting.lua: disabled google-java-format fallback for java (prefer JDTLS).
  - lua/cargdev/plugins/dap.lua: added additional DAP configs (Bun launch, attach helper), moved/registered dap keymaps here.
  - lua/cargdev/plugins/copilot.lua: reorganized Copilot/Copilot-cmp/CopilotChat config and added copilot source to nvim-cmp.
  - lua/cargdev/plugins/nvim-cmp.lua: added copilot source and small formatting tweak.
2026-02-10 12:17:36 -05:00

135 lines
4.6 KiB
Lua

-- ============================================================================
-- COPILOT: GitHub AI code completion and chat
-- ============================================================================
-- AI-powered code suggestions (ghost text + cmp menu) and chat.
-- Autocomplete: <C-l> accept ghost text, also shows in cmp menu.
-- Chat: <leader>cc toggle, <leader>cq quick chat, <leader>ce explain.
--
-- MODEL SELECTION:
-- Chat: :CopilotChatModels (pick from gpt-4o, claude-sonnet-4, o3-mini, etc.)
-- Autocomplete: controlled server-side by GitHub, not user-selectable.
-- ============================================================================
return {
-- Copilot core: ghost text suggestions + LSP backend
{
"zbirenbaum/copilot.lua",
cmd = "Copilot",
event = "InsertEnter",
config = function()
require("copilot").setup({
copilot_model = "gpt-41-copilot",
panel = {
enabled = true,
auto_refresh = false,
layout = {
position = "bottom",
ratio = 0.4,
},
},
suggestion = {
enabled = true,
auto_trigger = true,
debounce = 75,
keymap = {
accept = "<C-l>",
next = "<M-]>",
prev = "<M-[>",
dismiss = "<C-]>",
},
},
filetypes = {
markdown = true,
help = true,
gitcommit = true,
gitrebase = true,
hgcommit = true,
svn = true,
cvs = true,
tex = false,
["."] = true,
},
copilot_node_command = "node",
server_opts_overrides = {},
})
-- Disable Copilot when opening .tex files
vim.api.nvim_create_autocmd({ "FileType", "BufEnter" }, {
pattern = "tex",
callback = function()
local ok, suggestion = pcall(require, "copilot.suggestion")
if ok and suggestion and suggestion.is_visible() then
suggestion.dismiss()
end
vim.cmd("Copilot disable")
end,
desc = "Disable Copilot for LaTeX files",
})
end,
},
-- Copilot CMP: adds Copilot as a completion source in nvim-cmp menu
{
"zbirenbaum/copilot-cmp",
dependencies = { "zbirenbaum/copilot.lua" },
config = function()
require("copilot_cmp").setup()
end,
},
-- CopilotChat: full chat interface with model selection
{
"CopilotC-Nvim/CopilotChat.nvim",
dependencies = {
"zbirenbaum/copilot.lua",
"nvim-lua/plenary.nvim",
},
build = "make tiktoken",
cmd = {
"CopilotChat",
"CopilotChatToggle",
"CopilotChatModels",
"CopilotChatExplain",
"CopilotChatReview",
"CopilotChatFix",
"CopilotChatOptimize",
"CopilotChatDocs",
"CopilotChatTests",
"CopilotChatCommit",
},
keys = {
{ "<leader>cc", "<cmd>CopilotChatToggle<cr>", desc = "CopilotChat: Toggle chat window" },
{ "<leader>cq", function()
local input = vim.fn.input("Quick Chat: ")
if input ~= "" then
require("CopilotChat").ask(input, { selection = require("CopilotChat.select").buffer })
end
end, desc = "CopilotChat: Quick chat (whole buffer)" },
{ "<leader>ce", "<cmd>CopilotChatExplain<cr>", mode = { "n", "v" }, desc = "CopilotChat: Explain code" },
{ "<leader>cr", "<cmd>CopilotChatReview<cr>", mode = { "n", "v" }, desc = "CopilotChat: Review code" },
{ "<leader>cf", "<cmd>CopilotChatFix<cr>", mode = { "n", "v" }, desc = "CopilotChat: Fix code" },
{ "<leader>co", "<cmd>CopilotChatOptimize<cr>", mode = { "n", "v" }, desc = "CopilotChat: Optimize code" },
{ "<leader>cd", "<cmd>CopilotChatDocs<cr>", mode = { "n", "v" }, desc = "CopilotChat: Generate docs" },
{ "<leader>ct", "<cmd>CopilotChatTests<cr>", mode = { "n", "v" }, desc = "CopilotChat: Generate tests" },
{ "<leader>cm", "<cmd>CopilotChatModels<cr>", desc = "CopilotChat: Select model" },
},
config = function()
require("CopilotChat").setup({
-- Default model (change with :CopilotChatModels at runtime)
-- Options include: gpt-4o, claude-sonnet-4, o3-mini, gemini-2.0-flash, etc.
model = "claude-sonnet-4",
window = {
layout = "vertical",
width = 0.35,
border = "rounded",
},
mappings = {
complete = { insert = "<Tab>" },
close = { normal = "q", insert = "<C-c>" },
reset = { normal = "<C-x>", insert = "<C-x>" },
submit_prompt = { normal = "<CR>", insert = "<C-s>" },
},
})
end,
},
}