Ogpt.nvim
Chat with Ollama/OpenRouter/Huggingface/TextGen/OpenAI/Gemini/Anthropic GPT Neovim Plugin: Effortless Natural Language Generation with LLM API
Install / Use
/learn @huynle/Ogpt.nvimQuality Score
Category
Customer SupportSupported Platforms
README
OGPT.nvim
Features
- Multiple Providers: OGPT.nvim can take multiple providers. Ollama, OpenAI, textgenui, Gemini, Anthropic, more if there are pull requests
- Mix-match Provider: default provider is used, but you can mix and match different provider AND specific model to different actions, at any point in your run or configurations.
- Interactive Q&A: Engage in interactive question-and-answer sessions with LLMs using an intuitive interface.
- Persona-based Conversations: Explore various perspectives and have conversations with different personas by selecting prompts from Awesome ChatGPT Prompts.
- Customizable Actions: Execute a range of actions utilizing the gpt model, such as grammar correction, translation, keyword generation, docstring creation, test addition, code optimization, summarization, bug fixing, code explanation, and code readability analysis. Additionally, you can define your own custom actions using a JSON file or just through plugin configurations.
Demo
Screencast from 2024-02-16 15-27-06.webm
Installation
If you do not specify a provider, ollama will be the default provider. http://localhost:11434
is your endpoint. mistral:7b will be your default if the configuration is not updated.
-- Simple, minimal Lazy.nvim configuration
{
"huynle/ogpt.nvim",
event = "VeryLazy",
opts = {
default_provider = "ollama",
providers = {
ollama = {
api_host = os.getenv("OLLAMA_API_HOST") or "http://localhost:11434",
api_key = os.getenv("OLLAMA_API_KEY") or "",
}
}
},
dependencies = {
"MunifTanjim/nui.nvim",
"nvim-lua/plenary.nvim",
"nvim-telescope/telescope.nvim"
}
}
Configuration
OGPT.nvim comes with the following defaults. You can override any of the fields by passing a config as setup parameters.
https://github.com/huynle/ogpt.nvim/blob/main/lua/ogpt/config.lua
Ollama Setup
OGPT is a Neovim plugin that allows you to effortlessly utilize the Ollama OGPT API, empowering you to generate natural language responses from Ollama directly within the editor in response to your prompts.
- Make sure you have
curlinstalled. - Have a local instance of Ollama running.
Custom Ollama API host with the configuration option api_host_cmd or
environment variable called $OLLAMA_API_HOST. It's useful if you run Ollama remotely.
Gemini, TextGenUI, OpenAI, Anthropic Setup
- not much here, you just have to get your API keys and provide that in your configuration. If your configuration files are public, you probably want to create environment variable for your API keys
Edgy.nvim setup

edgy.nvim plugin offers a side window (positioned to the right by default) that provides a parallel working space where you can work on your project while interacting with OGPT. Here is an example of an 'edgy' configuration.
{
{
"huynle/ogpt.nvim",
event = "VeryLazy",
opts = {
default_provider = "ollama",
edgy = true, -- enable this!
single_window = false, -- set this to true if you want only one OGPT window to appear at a time
providers = {
ollama = {
api_host = os.getenv("OLLAMA_API_HOST") or "http://localhost:11434",
api_key = os.getenv("OLLAMA_API_KEY") or "",
}
}
},
dependencies = {
"MunifTanjim/nui.nvim",
"nvim-lua/plenary.nvim",
"nvim-telescope/telescope.nvim"
}
},
{
"folke/edgy.nvim",
event = "VeryLazy",
init = function()
vim.opt.laststatus = 3
vim.opt.splitkeep = "screen" -- or "topline" or "screen"
end,
opts = {
exit_when_last = false,
animate = {
enabled = false,
},
wo = {
winbar = true,
winfixwidth = true,
winfixheight = false,
winhighlight = "WinBar:EdgyWinBar,Normal:EdgyNormal",
spell = false,
signcolumn = "no",
},
keys = {
-- -- close window
["q"] = function(win)
win:close()
end,
-- close sidebar
["Q"] = function(win)
win.view.edgebar:close()
end,
-- increase width
["<S-Right>"] = function(win)
win:resize("width", 3)
end,
-- decrease width
["<S-Left>"] = function(win)
win:resize("width", -3)
end,
-- increase height
["<S-Up>"] = function(win)
win:resize("height", 3)
end,
-- decrease height
["<S-Down>"] = function(win)
win:resize("height", -3)
end,
},
right = {
{
title = "OGPT Popup",
ft = "ogpt-popup",
size = { width = 0.2 },
wo = {
wrap = true,
},
},
{
title = "OGPT Parameters",
ft = "ogpt-parameters-window",
size = { height = 6 },
wo = {
wrap = true,
},
},
{
title = "OGPT Template",
ft = "ogpt-template",
size = { height = 6 },
},
{
title = "OGPT Sessions",
ft = "ogpt-sessions",
size = { height = 6 },
wo = {
wrap = true,
},
},
{
title = "OGPT System Input",
ft = "ogpt-system-window",
size = { height = 6 },
},
{
title = "OGPT",
ft = "ogpt-window",
size = { height = 0.5 },
wo = {
wrap = true,
},
},
{
title = "OGPT {{{selection}}}",
ft = "ogpt-selection",
size = { width = 80, height = 4 },
wo = {
wrap = true,
},
},
{
title = "OGPt {{{instruction}}}",
ft = "ogpt-instruction",
size = { width = 80, height = 4 },
wo = {
wrap = true,
},
},
{
title = "OGPT Chat",
ft = "ogpt-input",
size = { width = 80, height = 4 },
wo = {
wrap = true,
},
},
},
},
}
}
Usage
Plugin exposes following commands:
OGPT
OGPT command opens an interactive window to communicate with LLM backends. The interactive window consists of four panes:
- OGPT Chat: Input text area to write prompts.
- OGPT: Output text area printing responses from LLM.
- OGPT Parameters: (Toggled by <Ctrl-o>,) Parameter panel to display and modify LLM paramters.
- OGPT Sessions: (Toggled by <Ctrl-o>,) Sessions panel to display chat sessions.
Useful shortcuts
<table> <thead> <tr> <th>Area</th> <th>Default shortcuts</th> <th>Description</th> </tr> </thead> <tbody> <tr> <td rowspan=6>Common</td> <td>Ctrl-o</td> <td>Toggle parameter panel (OGPT Parameters) and sessions panel (OGPT Sessions).</td> </tr> <tr> <td>Ctrl-n</td> <td>Create a new session.</td> </tr> <tr> <td>Ctrl-c</td> <td>Close OGPT. </tr> <tr> <td>Ctrl-i</td> <td>Copy code in LLM's latest response in OGPT output text area. </tr> <tr> <td>Ctrl-x</td> <td>Stop generating response.</td> </tr> <tr> <td>Tab</td> <td>Cycle through panes.</td> </tr> <tr> <td rowspan=4>OGPT</td> <td>K</td> <td>Previous response.</td> </tr> <tr> <td>J</td> <td>Next response.</td> </tr> <tr> <td>Ctrl-u</td> <td>Scroll up.</td> </tr> <tr> <td>Ctrl-d</td> <td>Scroll down.</td> </tr> <tr> <td rowspan=5>OGPT Chat</td> <td>Enter<br>(normal mode)</td> <td>Send prompt to LLM.</td> </tr> <tr> <td>Alt-Enter<br>(input mode)</td> <td>Send prompt to LLM.</td> </tr> <tr> <td>Ctrl-y</td> <td>Copy the latest response from LLM in OGPT output text area.</td> </tr> <tr> <td>Ctrl-r</td> <td>Toggle role (assistant or user).</td> </tr> <tr> <td>Ctrl-s</td> <td>Toggle system message.</td> </tr> <tr> <td rowspan=1>OGPT Parameters</td> <td>Enter</td> <td>Change parameter.</td> </tr> <tr> <td rowspan=3>OGPT Sessions</td> <td>Enter</td> <td>Switch session.</td> </tr> <tr> <td>d</td> <td>Delete session.</td> </tr> <tr> <td>r</td> <td>Rename session. Note that an active session cannot be removed.</td> </tr> </tbody> </table> <!-- Someone please fix the ugly HTML table to Markdown table --> <!-- Area | Default shortcuts | Description --> <!-- ---- | ---- | ---- --> <!-- Common | Ctrl-o | Toggle parameter panel (OGPT Parameters) and sessions panel (OGPT Sessions). --> <!-- ^ | Ctrl-n | Create a new session. --> <!-- ^ | q | Close OGPT. --> <!-- ^ | Ctrl-c | Close OGPT. --> <!-- ^ | Ctrl-i | Copy code in LLM's latest response in OGPT output text area. --> <!-- ^ | Ctrl-c | Close OGPT. --> <!-- ^ | Ctrl-x | Stop generating response. --Related Skills
async-pr-review
99.3kTrigger this skill when the user wants to start an asynchronous PR review, run background checks on a PR, or check the status of a previously started async PR review.
ci
99.3kCI Replicate & Status This skill enables the agent to efficiently monitor GitHub Actions, triage failures, and bridge remote CI errors to local development. It defaults to automatic replication
code-reviewer
99.3kCode Reviewer This skill guides the agent in conducting professional and thorough code reviews for both local development and remote Pull Requests. Workflow 1. Determine Review Target
docs-writer
99.3k`docs-writer` skill instructions As an expert technical writer and editor for the Gemini CLI project, you produce accurate, clear, and consistent documentation. When asked to write, edit, or revie
