@@ -221,3 +221,57 @@ map("n", "<leader><tab><tab>", "<cmd>tabnew<cr>", { desc = "New Tab" })
221221map (" n" , " <leader><tab>]" , " <cmd>tabnext<cr>" , { desc = " Next Tab" })
222222map (" n" , " <leader><tab>d" , " <cmd>tabclose<cr>" , { desc = " Close Tab" })
223223map (" n" , " <leader><tab>[" , " <cmd>tabprevious<cr>" , { desc = " Previous Tab" })
224+
225+ -- amp
226+ map (" n" , " <leader>as" , function ()
227+ vim .ui .input ({ prompt = " Amp: " }, function (input )
228+ if input and input ~= " " then
229+ require (" amp.message" ).send_message (input )
230+ end
231+ end )
232+ end , { desc = " Send Message" })
233+ map (" n" , " <leader>ab" , function ()
234+ local lines = vim .api .nvim_buf_get_lines (0 , 0 , - 1 , false )
235+ require (" amp.message" ).send_message (table.concat (lines , " \n " ))
236+ end , { desc = " Send Buffer" })
237+ map (" v" , " <leader>as" , function ()
238+ local start_line = vim .fn .line (" v" )
239+ local end_line = vim .fn .line (" ." )
240+ if start_line > end_line then
241+ start_line , end_line = end_line , start_line
242+ end
243+ local lines = vim .api .nvim_buf_get_lines (0 , start_line - 1 , end_line , false )
244+ require (" amp.message" ).send_message (table.concat (lines , " \n " ))
245+ end , { desc = " Send Selection" })
246+ map (" v" , " <leader>ap" , function ()
247+ local start_line = vim .fn .line (" v" )
248+ local end_line = vim .fn .line (" ." )
249+ if start_line > end_line then
250+ start_line , end_line = end_line , start_line
251+ end
252+ local lines = vim .api .nvim_buf_get_lines (0 , start_line - 1 , end_line , false )
253+ require (" amp.message" ).send_to_prompt (table.concat (lines , " \n " ))
254+ end , { desc = " Add Selection to Prompt" })
255+ map ({ " n" , " v" }, " <leader>ar" , function ()
256+ local bufname = vim .api .nvim_buf_get_name (0 )
257+ if bufname == " " then
258+ vim .notify (" Current buffer has no filename" , vim .log .levels .WARN )
259+ return
260+ end
261+ local relative_path = vim .fn .fnamemodify (bufname , " :." )
262+ local ref = " @" .. relative_path
263+ local mode = vim .fn .mode ()
264+ if mode == " v" or mode == " V" then
265+ local start_line = vim .fn .line (" v" )
266+ local end_line = vim .fn .line (" ." )
267+ if start_line > end_line then
268+ start_line , end_line = end_line , start_line
269+ end
270+ if start_line ~= end_line then
271+ ref = ref .. " #L" .. start_line .. " -" .. end_line
272+ else
273+ ref = ref .. " #L" .. start_line
274+ end
275+ end
276+ require (" amp.message" ).send_to_prompt (ref )
277+ end , { desc = " Add File Ref to Prompt" })
0 commit comments