frankroeder / parrot.nvim

parrot.nvim 🦜 - the plugin that brings stochastic parrots to Neovim. This is a gp.nvim-fork focused on simplicity.
Other
283 stars 18 forks source link

Docs regarding templates with `ChatToggle` #35

Closed RobertBrunhage closed 3 months ago

RobertBrunhage commented 3 months ago

There is no clear documentation in how to add in hooks with a new / toggle chat but only with popups.

For example in the cursor editor you would do <cmd>+l which would have the context of the current file and put you into chat mode, tapping it again would close and then open with a new chat instance with the current file context. If you would open a new file it would do the same with that as the current file context.

Often times it doesn't get it right the first time and you would have to do additional prompting to get into a good state, so a popup without chat doesn't really cut it most of the time.

frankroeder commented 3 months ago

I agree. Currently, there is no way to provide the agent with a default prompt when opening a chat. It should be possible to create hooks that initiate a new chat with a predefined template. This should go beyond the system prompts: https://github.com/frankroeder/parrot.nvim/blob/1e9af4dc93a06d3f21f6f9b314e79b236971f551/lua/parrot/agents/init.lua#L8-L28

RobertBrunhage commented 3 months ago

Would the workaround for this currently be to open a new chat and paste in the file contents of the current file and then ask the question? Using templates doesn't seem possible within a chat from my understanding.

frankroeder commented 3 months ago

I am working on a solution for templates or something related to custom chat hooks. Currently, it is not possible.

Yes, you can directly open a chat with the content of the file by visually selecting it and invoking PrtChatNew, or you can paste your visual selection into your latest chat with PrtPaste afterward.

RobertBrunhage commented 3 months ago

Got it, written these as workarounds for now!

vim.keymap.set("n", "<leader>pt", "<cmd>PrtChatToggle<cr>")
vim.keymap.set("n", "<leader>pc", "ggVG:PrtChatNew<cr>")
vim.keymap.set("n", "<leader>pr", "<cmd>PrtChatRespond<cr>")
vim.keymap.set("v", "<leader>pi", ":PrtRewrite<cr>")
frankroeder commented 3 months ago

I have added a lightweight chat template support in the following commit: https://github.com/frankroeder/parrot.nvim/commit/20861f6ce3eeaf1d9c309df92c03972a5ec54e83

RobertBrunhage commented 3 months ago

awesome, thanks @frankroeder !