gsuuon / model.nvim

Neovim plugin for interacting with LLM's and building editor integrated prompts.
MIT License
293 stars 21 forks source link

Proposal: Use tree-sitter for highlighting in chat sessions #44

Closed murtaza64 closed 2 months ago

murtaza64 commented 6 months ago

If we were to use tree-sitter for highlighting mchat buffers, we would be able to leverage injections to highlight code snippets correctly. tree-sitter-markdown already implements this, and chatbots usually respond with valid markdown, so this wouldn't be too much of a lift. We would probably have to figure out how to deliver the tree-sitter parser to users, whether by putting it in the nvim-treesitter repo or some other way. I'm willing to look into this and create a PR--is this something you'd be interested in merging?

gsuuon commented 6 months ago

Absolutely! This was the plan, the syntax based highlighting was really just to test out the idea. Would definitely welcome a PR.

As for delivery, we can just start with a separate repo that users install with https://github.com/nvim-treesitter/nvim-treesitter?tab=readme-ov-file#adding-parsers

murtaza64 commented 6 months ago

I'm gonna take a crack at this over the next couple weeks between work! I have some experience with tree-sitter grammars, and I think it'll be relatively simple to get something good. I hope you don't mind if I also experiment with the format of the chat session itself a bit for readability and clarity

gsuuon commented 6 months ago

Sounds good! The format is not set in stone. The goal is something like a living record. It should be readable as a chat log without the plugin at all, but with the plugin the chat can be continued.

murtaza64 commented 5 months ago

I ended up being pretty busy this week so not sure when I'll have time to work on this actively. If anyone else wants to take a stab at it in the meantime, go for it (and let me know so we don't duplicate work)