Skip to content
This repository has been archived by the owner on Jan 20, 2024. It is now read-only.

Interact with ai chatbots in an editable markdown buffer. Currently only supports one of openai's endpoints, may never support more.

Notifications You must be signed in to change notification settings

jay-aye-see-kay/chatbot-buffer.nvim

Repository files navigation

Archive notice

I recently learnt about https://github.com/Robitx/gp.nvim and found it's really close to what I was trying to build with a bunch of great features already implemented. I was using this plugin but not adding the features I wanted, archiving so it's clear I won't add any new features.

Chatbot-buffer.nvim

This is a plugin for interacting with the openai chat api. It's distinctive feature is that the conversation happens in a regular editable buffer so that it plays nicely with other vim plugins and so the user can revise the conversation history before continuing it.

Requires plenary.nvim, curl, and a openai api token in the environment variable OPENAI_API_TOKEN.

State of this plugin

This plugin is very work in progress, as in it only just works. There's no docs yet, read the source code (currently <300 lines in one file). Contributions and ideas welcome. Unless you really like exactly what I'm making here I'd recommend one of these two plugins instead:

Planned features

  • Handle error states better, currently if not online it just says loading forever, not sure what happens if openai's api is down or erroring
  • Using virtual text for error and loading state (and maybe expose a function so it could be put in a status line)
  • Use the streaming api so tokens can be added to the buffer immediately (1 token per ~100ms instead of the whole lot in 3-10 sec)
    • Is it possible to cancel a streaming response part way through, so we can shut it up when it's waffling? That would be sweet
  • Add some formatting and/or concealing to the section markers
  • Opt-in debug logging that saves all curl requests and responses to file

Development

Run tests

tests/init.lua will download plenary to .tests/ on first run.

Assuming you have just installed, run tests with: (if you don't have just installed read the justfile for the command to run)

# run all tests
just test

# run one test
just test tests/files_spec.lua

# run tests on any lua file change (requires entr to to be installed)
ls **/*.lua | entr just test

About

Interact with ai chatbots in an editable markdown buffer. Currently only supports one of openai's endpoints, may never support more.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published