{"id":13410100,"url":"https://github.com/CamdenClark/flyboy","last_synced_at":"2025-03-14T15:31:46.112Z","repository":{"id":189262784,"uuid":"620602384","full_name":"CamdenClark/flyboy","owner":"CamdenClark","description":"a lightweight ChatGPT plugin for neovim","archived":false,"fork":false,"pushed_at":"2023-10-31T23:19:11.000Z","size":66,"stargazers_count":40,"open_issues_count":1,"forks_count":3,"subscribers_count":3,"default_branch":"main","last_synced_at":"2024-07-31T20:40:39.735Z","etag":null,"topics":["chatgpt","lua","neovim"],"latest_commit_sha":null,"homepage":"","language":"Lua","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/CamdenClark.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null}},"created_at":"2023-03-29T02:20:54.000Z","updated_at":"2024-04-24T22:50:18.000Z","dependencies_parsed_at":"2024-01-03T03:39:33.297Z","dependency_job_id":null,"html_url":"https://github.com/CamdenClark/flyboy","commit_stats":null,"previous_names":["camdenclark/flyboy"],"tags_count":0,"template":false,"template_full_name":"nvim-lua/nvim-lua-plugin-template","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/CamdenClark%2Fflyboy","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/CamdenClark%2Fflyboy/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/CamdenClark%2Fflyboy/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/CamdenClark%2Fflyboy/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/CamdenClark","download_url":"https://codeload.github.com/CamdenClark/flyboy/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243600652,"owners_count":20317311,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["chatgpt","lua","neovim"],"created_at":"2024-07-30T20:01:04.971Z","updated_at":"2025-03-14T15:31:45.767Z","avatar_url":"https://github.com/CamdenClark.png","language":"Lua","readme":"# flyboy\n\nFlyboy is a plugin for lightweight interaction with ChatGPT.\n\n\u003c!-- markdownlint-disable-next-line no-bare-urls --\u003e\nhttps://github.com/CamdenClark/flyboy/assets/11891578/3e3fdf5d-25cc-4691-bf25-0abd0a228424\n\nIt works by using a simple Markdown format, as follows:\n\n```markdown\n# User\n\nWho was the 1st president of the United States?\n\n# Assistant\n\nGeorge Washington\n\n# User\n```\n\nThis makes it easy to:\n\n1. Start chats\n1. Save/share chats\n1. Edit conversations in line\n1. Have multi-turn conversations\n\nNo popups that take over your screen, flyboy operates on any buffer.\n\nFlyboy also supports configuring custom templates, so you can go straight from\nyour buffer to ChatGPT with context:\n\n```markdown\n# User\n\nWrite a unit test in Lua for the following code\n\u003cYour code from visual selection here\u003e\n```\n\n\n## Installation\n\n1. Put your `OPENAI_API_KEY` as an environment variable\n\n```bash\nexport OPENAI_API_KEY=\"\"\n```\n\n2. Have curl installed on your machine\n\n3. Install `plenary.nvim` and `flyboy` using your package manager:\n\nFor example, using plug\n\n```vim\nPlug 'nvim-lua/plenary.nvim'\nPlug 'CamdenClark/flyboy'\n```\n\n## Usage\n\n`:FlyboyOpen` functions open a new chat window. Split opens in a horizontal split,\nwhile VSplit opens in a vertical split. They optionally take a template.\n\n```vim\n:FlyboyOpen\n:FlyboyOpenSplit\n:FlyboyOpenVSplit\n\n\" open a chat buffer with the current text selected in visual mode\n:FlyboyOpen visual\n```\n\n`:FlyboyStart` functions open a new chat window and automatically send the message to the\nassistant. You need to provide a template or the first message sent will be blank.\n\n```vim\n\" starts a chat session with the current text selected in visual mode\n:FlyboyStart visual\n:FlyboyStartSplit visual\n:FlyboyStartVSplit visual\n```\n\nTo send a message:\n\n```vim\n:FlyboySendMessage\n```\n\nThe response from the Assistant will be streamed back to the same buffer.\n\n## Configuration\n\n### Templates\n\nYou can configure custom sources and templates for your ChatGPT prompts.\n\n```lua\nrequire('flyboy.config').setup({\n  sources = {\n    my_source = function () return \"world\" end\n  },\n  templates = {\n    my_template = {\n      template_fn = function(sources) return \"# User\\nHello, \" .. sources.my_source() end\n      -- :FlyboyOpen my_template\n      -- Output:\n      -- # User\n      -- Hello, world\n    }\n  }\n})\n```\n\nSources are intended to be helpers to get common pieces of data that you'd be\ninterested in to build your prompts to ChatGPT. Some sources are pre-created,\nincluding `visual`, which provides the text that's visually selected.\n\nTemplates are how you construct prompts that will be sent to ChatGPT.\n\n#### Visual selection\n\nFlyboy supports adding something you've selected in visual mode to the contents\nof a prompt:\n\n```lua\nrequire('flyboy.config').setup({\n  templates = {\n    unit_test = {\n      template_fn = function(sources)\n          return \"# User\\n\"\n            .. \"Write a unit test for the following code:\\n\"\n            .. sources.visual()\n      end\n      -- :FlyboyStart unit_test\n      -- Output:\n      -- # User\n      -- Write a unit test for the following\n      -- \u003cYour visual selection\u003e\n    }\n  }\n})\n```\n\n#### Buffer selection\n\nFlyboy supports adding the contents of your current buffer to a prompt:\n\n```lua\nrequire('flyboy.config').setup({\n  templates = {\n    unit_test_buffer = {\n      template_fn = function(sources)\n          return \"# User\\n\"\n            .. \"Write unit tests for the code in the following file:\\n\"\n            .. sources.buffer()\n      end\n      -- :FlyboyStart unit_test_buffer\n      -- Output:\n      -- # User\n      -- Write a unit test for the following\n      -- \u003cYour previous buffer's contents\u003e\n    }\n  }\n})\n```\n\n### Alternative models: gpt-3.5-turbo-16k / gpt-4 / gpt-4-32k\n\nIf you want to use Flyboy with a different model in OpenAI, call setup with the model:\n\n```lua\nrequire('flyboy.config').setup({\n  -- ...\n  model = \"gpt-4\"\n})\n```\n\nTo change on the fly, call `:FlyboySwitchModel gpt-4`\n\n### Alternative endpoints (Azure OpenAI)\n\nFlyboy supports configuring the URL and headers with a different endpoint that shares API compatibility (IE: Azure OpenAI)\nwith OpenAI, here's a reference implementation:\n\n```lua\nrequire('flyboy.config').setup({\n  -- should be like \"$AZURE_OPENAI_ENDPOINT/openai/deployments/gpt-35-turbo/chat/completions?api-version=2023-07-01-preview\"\n  url = vim.env.AZURE_OPENAI_GPT4_URL,\n  headers = { \n    Api_Key = vim.env.AZURE_OPENAI_GPT4_KEY,\n    Content_Type = \"application/json\"\n  }\n})\n```\n\nwhere you put the values for `AZURE_OPENAI_GPT4_URL` and `AZURE_OPENAI_GPT4_KEY` in the environment.\n\nIf you want to be able to switch URLs based on model, you should make some lua functions in your\ninit.lua that are bound to re-call setup with the updated URL and API key.\n\n### Callback when message finished\n\nFlyboy supports configuring a callback function that is called when a response from the assistant finishes streaming.\n\n```lua\nrequire('flyboy.config').setup({\n  on_complete = function() print(\"foo\") end\n})\n```\n\n## Development\n\n### Run tests\n\nRunning tests requires [plenary.nvim][plenary] to be checked out in the parent directory of _this_ repository.\nYou can then run:\n\n```bash\njust test\n```\n\nor, more verbose:\n\n```bash\nnvim --headless --noplugin -u tests/minimal.vim -c \"PlenaryBustedDirectory tests/ {minimal_init = 'tests/minimal.vim'}\"\n```\n\nOr if you want to run a single test file:\n\n```bash\njust test chat_spec.lua\n```\n\n```bash\nnvim --headless --noplugin -u tests/minimal.vim -c \"PlenaryBustedDirectory tests/path_to_file.lua {minimal_init = 'tests/minimal.vim'}\"\n```\n\nRead the [nvim-lua-guide][nvim-lua-guide] for more information on developing neovim plugins.\n\n[nvim-lua-guide]: https://github.com/nanotee/nvim-lua-guide\n[plenary]: https://github.com/nvim-lua/plenary.nvim\n","funding_links":[],"categories":["AI","Lua","Conversation-focused"],"sub_categories":["(requires Neovim 0.5)","Diagnostics"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FCamdenClark%2Fflyboy","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FCamdenClark%2Fflyboy","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FCamdenClark%2Fflyboy/lists"}