diff --git a/.config/nvim/lua/lazyvim/plugins/amp.lua b/.config/nvim/lua/lazyvim/plugins/amp.lua index d4e93af..ff4b1c5 100644 --- a/.config/nvim/lua/lazyvim/plugins/amp.lua +++ b/.config/nvim/lua/lazyvim/plugins/amp.lua @@ -4,5 +4,78 @@ return { branch = "main", lazy = false, opts = { auto_start = true, log_level = "info" }, + keys = { + { "am", "AmpSend", desc = "Send a quick message" }, + { "ab", "AmpSendBuffer", desc = "Send buffer contents" }, + { "as", "AmpPromptSelection", desc = "Send selection" }, + { "af", "AmpPromptRef", desc = "Add file + selection" }, + }, + config = function() + -- Send a quick message to the agent + vim.api.nvim_create_user_command("AmpSend", function(opts) + local message = opts.args + if message == "" then + message = vim.fn.input("Message: ") + if message == "" then + print("Please provide a message to send") + return + end + end + + local amp_message = require("amp.message") + amp_message.send_message(message) + end, { + nargs = "*", + desc = "Send a message to Amp", + }) + + -- Send entire buffer contents + vim.api.nvim_create_user_command("AmpSendBuffer", function(opts) + local buf = vim.api.nvim_get_current_buf() + local lines = vim.api.nvim_buf_get_lines(buf, 0, -1, false) + local content = table.concat(lines, "\n") + + local amp_message = require("amp.message") + amp_message.send_message(content) + end, { + nargs = "?", + desc = "Send current buffer contents to Amp", + }) + + -- Add selected text directly to prompt + vim.api.nvim_create_user_command("AmpPromptSelection", function(opts) + local lines = vim.api.nvim_buf_get_lines(0, opts.line1 - 1, opts.line2, false) + local text = table.concat(lines, "\n") + + local amp_message = require("amp.message") + amp_message.send_to_prompt(text) + end, { + range = true, + desc = "Add selected text to Amp prompt", + }) + + -- Add file+selection reference to prompt + vim.api.nvim_create_user_command("AmpPromptRef", function(opts) + local bufname = vim.api.nvim_buf_get_name(0) + if bufname == "" then + print("Current buffer has no filename") + return + end + + local relative_path = vim.fn.fnamemodify(bufname, ":.") + local ref = "@" .. relative_path + if opts.line1 ~= opts.line2 then + ref = ref .. "#L" .. opts.line1 .. "-" .. opts.line2 + elseif opts.line1 > 1 then + ref = ref .. "#L" .. opts.line1 + end + + local amp_message = require("amp.message") + amp_message.send_to_prompt(ref) + end, { + range = true, + desc = "Add file reference (with selection) to Amp prompt", + }) + end, }, } diff --git a/.config/nvim/lua/lazyvim/plugins/angular.lua b/.config/nvim/lua/lazyvim/plugins/angular.lua index da07e52..b9cc1d8 100644 --- a/.config/nvim/lua/lazyvim/plugins/angular.lua +++ b/.config/nvim/lua/lazyvim/plugins/angular.lua @@ -1,16 +1,16 @@ return { - { - "joeveiga/ng.nvim", - enabled = true, - lazy = false, - config = function() - local ng = require("ng"); - vim.keymap.set("n", "at", function() - ng.goto_template_for_component({ reuse_window = true }) - end, { desc = "Go to template" }) - vim.keymap.set("n", "ac", function() - ng.goto_component_with_template_file({ reuse_window = true }) - end, { desc = "Go to component" }) - end, - }, + { + "joeveiga/ng.nvim", + enabled = true, + lazy = false, + config = function() + local ng = require("ng") + vim.keymap.set("n", "At", function() + ng.goto_template_for_component({ reuse_window = true }) + end, { desc = "Go to template" }) + vim.keymap.set("n", "Ac", function() + ng.goto_component_with_template_file({ reuse_window = true }) + end, { desc = "Go to component" }) + end, + }, }