A minimal Neovim plugin (Lua) to chat with a local Ollama instance in a dedicated chat tab, send visual selections, entire buffers, or a set of added buffers to the model, and keep read-only chat history in that tab.
:OllamaChat [model]— open a new chat tab with a read-only chat buffer.:OllamaAsk {text}— send a one-off prompt to the current chat session.:OllamaChatClose— close the chat tab and destroy its buffer.:OllamaSendSelection— send the current visual selection as context/prompt.:OllamaSendBuffer— send the entire current buffer content.:OllamaAddBuffer— add the current buffer to the session's context list.:OllamaClearAddedBuffers— clear the context buffer list for the session.:OllamaSendAddedBuffers— send the concatenated contents of all added buffers.:OllamaModel [model]— set/get model name for the current chat.:OllamaSetServer {url}— change the server URL (default:http://127.0.0.1:11434).
The chat buffer is read-only; you interact using commands. History remains visible within the tab.
This plugin uses externalcurlto call Ollama's HTTP API (/api/generate) either buffered/streamed to neovim, or not (set in config with stream=true|false).
- Neovim 0.8+
- A running Ollama server (default:
http://127.0.0.1:11434) curlavailable on your system
{
"thgrass/neollama.nvim",
config = function()
require("ollama_chat").setup({
server_url = "http://127.0.0.1:11434",
model = "llama3.1",
stream = true,
})
end,
}use({
"thgrass/neollama.nvim",
config = function()
require("ollama_chat").setup({})
end,
})Or install manually by copying this folder into your neovim runtimepath.
-
Start a chat tab:
:OllamaChat " start with default model :OllamaChat mistral " start with model mistral
-
Ask something directly:
:OllamaAsk What is the time complexity of quicksort? -
From another buffer, send the current visual selection:
- Select text in Visual mode, then:
:OllamaSendSelection
- Select text in Visual mode, then:
-
Send the entire buffer:
:OllamaSendBuffer
-
Build a multi-file context:
:OllamaAddBuffer " run in buffers you want to add :OllamaSendAddedBuffers " send all added buffers together :OllamaClearAddedBuffers " clear the list
-
Change model for the current chat:
:OllamaModel mistral " set model to mistral :OllamaModel " prints current model
-
Change server URL:
:OllamaSetServer http://localhost:11434
-
Close Chat Tab & Destroy Chat Buffer:
:OllamaChatClose
- Add chat history to model context.
- Add support for model prompts and other variables.
- Improve support for programming tasks.
- ...
MIT