Robitx / gp.nvim

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

feat: add `config.chat_template` to be able to customize the chat file banner #117

Closed argshook closed 2 months ago

argshook commented 6 months ago

Hello again :wave:

Your plugin is still amazing, thanks once more for working on it and keeping it open source!


This PR adds a new config option: chat_template. The default messaging is good, but as i'm familiar with how the plugin works, I don't need to be reminded about the shortcuts each time.

Therefore, i'd like to configure that message, but couldn't find a way to do so. Maybe i missed it?

A bit naive but very simple way is to expose chat_template to be configurable. If user decides to set it, then it is up to them to set it correctly.

If chat_template is not set, nothing changes and the current message is shown. So no impact for existing users.

Having chat_template config option i'm able to:

require("gp").setup({
  chat_user_prefix = "🗨:",
  chat_template = "# topic: ?\n\n"
    .. "- file: %s\n"
    .. "---\n"
    .. "🗨: "
})

and now each chat file looks like:

# topic: ?

- file: 2024-03-13.19-09-31.030.md
---
🗨:

which is neat, much cleaner!


additional thought is that perhaps markdown frontmatter would fit here for the banner? It is often used to set some extra properties that are not part of markdown body. Lua probably already has some utilities to deal with frontmatter, so chances are it might be easy addition (i'm lua noob, i wouldn't know!).

Anyway, thanks for the plugin, just wanted to share my 2 cents.

Cheers!

marcomayer commented 3 months ago

just what I was looking for...hope this gets merged soon 🤞

argshook commented 3 months ago

Hey @marcomayer 👋🏻 you can try out my fork, until (and if) this gets merged to upstream.

Wrote about how to do that here

i see this PR now includes more than needed, because it points to the main branch of my fork, instead of a more appropriate one.

I'll try to remember about it and find time to update 🤞🏻

Robitx commented 2 months ago

@argshook Hey, I've cherry picked and slightly adjusted the

argshook commented 2 months ago

Hey @Robitx 👋🏻

this is great, thanks a lot! and pardon for leaving the PR in such a state, my mistake for pointing the PR from main branch of my fork.

Anyway, thanks for your work, the plugin is still kickin'!