Skip to content

Commit

Permalink
Fix cmp and copilot, minor improvement
Browse files Browse the repository at this point in the history
  • Loading branch information
utensil committed Oct 31, 2024
1 parent e481cd5 commit 25c0b93
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 56 deletions.
5 changes: 4 additions & 1 deletion trees/uts-002F.tree
Original file line number Diff line number Diff line change
Expand Up @@ -274,7 +274,10 @@ It's very important to stay in the flow and Zen mode as much as possible. Split
- LLM Chats
- Github Copilot
- `<leader>+aa` to toggle the chat, `<leader>+al` to clear chat history
- **e**xplain, **r**eview, **R**factor, **t**est, **d**ebug, **f**ix, co**m**mit log, **n**aming etc.
- `<leader>+a` + a character
- for selected code block, **e**xplain, **r**eview, **o**ptimize, **R**factor, **t**est
- **d**ebug, **f**ix, co**m**mit log, **n**aming etc.
- `?` to select the model
- `C-s` to send the prompt
- Avante
- `<leader>+aa` to open the chat, use `a` to accept individual suggestions, or `A` to accept all
Expand Down
79 changes: 24 additions & 55 deletions uts-plugins.lua
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,6 @@ local plugins = {
-- return col ~= 0
-- and vim.api.nvim_buf_get_lines(0, line - 1, line, true)[1]:sub(col, col):match "%s" == nil
-- end

-- opts.mapping = vim.tbl_extend("force", opts.mapping, {
-- ["<Tab>"] = cmp.mapping(function(fallback)
-- local copilot_ok, copilot_suggestion = pcall(require, "copilot.suggestion")
Expand Down Expand Up @@ -208,18 +207,7 @@ local plugins = {
-- })
-- end,
-- },
{
"zbirenbaum/copilot-cmp",
after = {
"copilot.vim",
-- "copilot.lua",
"nvim-cmp",
},
config = function()
require("copilot_cmp").setup()
end,
},
{ "hrsh7th/cmp-emoji" },

-- adapted from https://github.com/jellydn/lazy-nvim-ide/blob/main/lua/plugins/extras/copilot-chat-v2.lua
-- config = function(_, opts)
-- local chat = require "CopilotChat"
Expand Down Expand Up @@ -283,25 +271,17 @@ local plugins = {
-- end,
keys = {
-- Code related commands
{ "<leader>ae", "<cmd>CopilotChatExplain<cr>", desc = "CopilotChat - Explain code" },
{ "<leader>at", "<cmd>CopilotChatTests<cr>", desc = "CopilotChat - Generate tests" },
{ "<leader>ar", "<cmd>CopilotChatReview<cr>", desc = "CopilotChat - Review code" },
{ "<leader>aR", "<cmd>CopilotChatRefactor<cr>", desc = "CopilotChat - Refactor code" },
{ "<leader>an", "<cmd>CopilotChatBetterNamings<cr>", desc = "CopilotChat - Better Naming" },
-- -- Chat with Copilot in visual mode
-- {
-- "<leader>av",
-- "<cmd>CopilotChatVisual<cr>",
-- mode = "x",
-- desc = "CopilotChat - Open in vertical split",
-- },
-- {
-- "<leader>ax",
-- "<cmd>CopilotChatInline<cr>",
-- mode = "x",
-- desc = "CopilotChat - Inline chat",
-- },
-- Custom input for CopilotChat
{ "<leader>ae", mode = "x", "<cmd>CopilotChatExplain<cr>", desc = "CopilotChat - Explain code" },
{ "<leader>at", mode = "x", "<cmd>CopilotChatTests<cr>", desc = "CopilotChat - Generate tests" },
{ "<leader>ar", mode = "x", "<cmd>CopilotChatReview<cr>", desc = "CopilotChat - Review code" },
{ "<leader>aR", mode = "x", "<cmd>CopilotChatRefactor<cr>", desc = "CopilotChat - Refactor code" },
{ "<leader>an", mode = "x", "<cmd>CopilotChatBetterNamings<cr>", desc = "CopilotChat - Better Naming" },
{ "<leader>ao", mode = "x", "<cmd>CopilotChatOptimize<cr>", desc = "CopilotChat - Optimize code" },
{ "<leader>ad", "<cmd>CopilotChatDebugInfo<cr>", desc = "CopilotChat - Debug Info" },
{ "<leader>af", "<cmd>CopilotChatFixDiagnostic<cr>", desc = "CopilotChat - Fix Diagnostic" },
{ "<leader>al", "<cmd>CopilotChatReset<cr>", desc = "CopilotChat - Clear buffer and chat history" },
{ "<leader>aa", "<cmd>CopilotChatToggle<cr>", desc = "CopilotChat - Toggle" },
{ "<leader>a?", "<cmd>CopilotChatModels<cr>", desc = "CopilotChat - Select Models" },
{
"<leader>ai",
function()
Expand All @@ -323,31 +303,20 @@ local plugins = {
"<cmd>CopilotChatCommitStaged<cr>",
desc = "CopilotChat - Generate commit message for staged changes",
},
-- -- Quick chat with Copilot
-- {
-- "<leader>aq",
-- function()
-- local input = vim.fn.input "Quick Chat: "
-- if input ~= "" then
-- vim.cmd("CopilotChatBuffer " .. input)
-- end
-- end,
-- desc = "CopilotChat - Quick chat",
-- },
-- Debug
{ "<leader>ad", "<cmd>CopilotChatDebugInfo<cr>", desc = "CopilotChat - Debug Info" },
-- Fix the issue with diagnostic
{ "<leader>af", "<cmd>CopilotChatFixDiagnostic<cr>", desc = "CopilotChat - Fix Diagnostic" },
-- Clear buffer and chat history
{ "<leader>al", "<cmd>CopilotChatReset<cr>", desc = "CopilotChat - Clear buffer and chat history" },
-- Toggle Copilot Chat Vsplit
{ "<leader>av", "<cmd>CopilotChatToggle<cr>", desc = "CopilotChat - Toggle" },
-- Also toggle, easier to type
{ "<leader>aa", "<cmd>CopilotChatToggle<cr>", desc = "CopilotChat - Toggle" },
-- Copilot Chat Models
{ "<leader>a?", "<cmd>CopilotChatModels<cr>", desc = "CopilotChat - Select Models" },
},
},
{
"zbirenbaum/copilot-cmp",
after = {
"copilot.vim",
-- "copilot.lua",
"nvim-cmp",
},
config = function()
require("copilot_cmp").setup()
end,
},
{ "hrsh7th/cmp-emoji" },
{
"Julian/lean.nvim",
event = { "BufReadPre *.lean", "BufNewFile *.lean" },
Expand Down

0 comments on commit 25c0b93

Please sign in to comment.