Robitx / gp.nvim

Gp.nvim (GPT prompt) Neovim AI plugin: ChatGPT sessions & Instructable text/code operations & Speech to text [OpenAI]
MIT License
537 stars 49 forks source link

feat: add option to set chat buftype to prompt #94

Closed lucobellic closed 5 months ago

lucobellic commented 5 months ago

Hello,

Is it possible to add an option to set the chat buftype to prompt?

Currently, I am setting it using ftplugin, and I find it to be a more natural way to interact with the chatbot. This is especially helpful for directly moving to the last line when entering insert mode and triggering GpChatRespond upon pressing Enter.

example with ftplugin/markdown.lua

```lua local buf = vim.api.nvim_get_current_buf() local win = vim.api.nvim_get_current_win() if require('util.util').is_gp_file(vim.api.nvim_buf_get_name(buf)) then vim.api.nvim_set_option_value('number', false, { win = win }) vim.api.nvim_set_option_value('spell', false, { win = win }) vim.diagnostic.disable(buf) vim.api.nvim_set_option_value('buftype', 'prompt', { buf = buf }) vim.fn.prompt_setcallback(buf, function() vim.api.nvim_command('GpChatRespond') end) vim.fn.prompt_setprompt(buf, '') end ```

I have reviewed the code and documentation but couldn't find this feature. My apologies if the feature already exists.

Edit: corrected code snippet

Robitx commented 5 months ago

@lucobellic hey, option chat_prompt_buf_type = true/false, is now available in the latest version.

Haven't touched the number/spell/diagnostic. At least numbering is still worth keeping even with prompt buffer (jumping around in normal/visual mode in order to copy something).