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

fix: set the popup window to markdown filetype #128

Closed XXiaoA closed 1 month ago

tanloong commented 2 months ago

This has a side effect. It applies the markdown type to not only popup windows but also the search bar in :GpChatFinder, which is created by the create_popup() function in the same way as popup windows.

I think a more proper solution would be to move the vim.api.nvim_buf_set_option(buf, "filetype", "markdown") to just below the 0read file_name line in the open_buf() function.

The popup for :GpChatNew works differently than other targets. :GpChatNew <target> first creates a .md file containing the template, and then uses the open_buf() function to read it in. When reading the template.md, all targets (split, vsplit, tabnew) except for popup simply open it, and the filetype is detected by checking the file name. The popup target, however, creates a new window and copy-pastes the content from the template.md, and the filetype is not detected and left empty.

XXiaoA commented 2 months ago

@tanloong Yeah, it was my mistake. I browsed the code base again and find it you are right. Thanks!

XXiaoA commented 2 months ago

I ran the git rebase, so that we only have one commit