| Key | Mode | Description |
|---|---|---|
<leader>aa | Normal | Toggle OpenCode sidebar |
<leader>as | Normal, Visual | Submit selected code to OpenCode |
<leader>ai | Normal, Visual | Ask OpenCode a question |
<leader>aI | Normal, Visual | Ask with current buffer context (@this:) |
<leader>ab | Normal, Visual | Ask about current file (@file) |
<leader>ap | Normal, Visual | Send custom prompt with context |
Overview
OpenCode is the default AI assistant in Gentleman.Dots, featuring a custom Gentleman agent configuration. It’s installed automatically with the setup script and includes a custom theme, modern CLI tools integration, and MCP support.OpenCode is enabled by default in
~/.config/nvim/lua/plugins/disabled.lua. All other AI plugins are disabled to avoid conflicts.Installation
OpenCode is automatically installed by the Gentleman.Dots setup script:Neovim Configuration
The OpenCode Neovim plugin is configured in~/.config/nvim/lua/plugins/opencode.lua:
Keybindings
Primary Commands
Primary Commands
Built-in Prompts
Built-in Prompts
| Key | Prompt | Description |
|---|---|---|
<leader>ape | explain | Explain selected code |
<leader>apf | fix | Fix issues in selected code |
<leader>apd | diagnose | Diagnose problems |
<leader>apr | review | Review code for best practices |
<leader>apt | test | Generate unit tests |
<leader>apo | optimize | Optimize performance |
Window Configuration
OpenCode Configuration File
The main configuration is stored in~/.config/opencode/opencode.json:
Configuration Options
| Option | Description | Default |
|---|---|---|
theme | OpenCode UI theme | gentleman |
autoupdate | Automatically update OpenCode CLI | true |
mcp | Model Context Protocol integrations | See below |
agent | Custom agent configurations | See below |
model | Default LLM model | OpenCode default |
MCP Integration
Model Context Protocol (MCP) enhances OpenCode’s ability to fetch up-to-date documentation:Context7 MCP
Provides real-time access to documentation, allowing the Gentleman agent to verify claims with current information.
Gentleman Theme
The custom Gentleman theme features:- Dark background for comfortable long coding sessions
- Kanagawa-inspired colors matching the Neovim theme
- Clean typography optimized for code readability
- Consistent visual language with the rest of the configuration
The theme is automatically applied when you run OpenCode. No additional configuration needed.
Model Configuration
You can specify a default model or per-agent model:- Global Model
- Per-Agent Model
Popular Model Options
| Provider | Model ID | Best For |
|---|---|---|
| Anthropic | anthropic/claude-sonnet-4-20250514 | General development, reasoning |
| Anthropic | anthropic/claude-haiku-4-20250514 | Fast responses, simple tasks |
| OpenAI | openai/gpt-4o | General development |
| OpenAI | openai/gpt-4o-mini | Quick tasks, cost-effective |
google/gemini-2.0-flash | Fast inference | |
google/gemini-2.5-pro-preview-06-05 | Advanced reasoning |
Using OpenCode
Neovim Integration Workflow
Send to OpenCode
Use
<leader>as to submit the selection, or use built-in prompts:<leader>ape- Explain<leader>apf- Fix<leader>apr- Review<leader>apt- Generate tests
Advanced Usage
Context Management
Working with Modern CLI Tools
The Gentleman agent prefers modern tools. When asking questions, it will use:Troubleshooting
OpenCode not found
OpenCode not found
The OpenCode CLI may not be installed or not in PATH:
Gentleman agent not available
Gentleman agent not available
The agent configuration may be missing:
Sidebar doesn't open
Sidebar doesn't open
Modern CLI tools not working
Modern CLI tools not working
Install missing tools:
Next Steps
Gentleman Agent
Learn about the agent’s philosophy, personality, and interaction style
Switch AI Plugins
Enable a different AI assistant like Avante or CopilotChat
AI Overview
Explore all available AI integration options