Neovim Integration Guide
Complete guide to using Radium with Neovim via the radium-nvim extension.
Prerequisitesβ
- Neovim 0.5+ (with Lua support)
- Radium CLI installed and in PATH
- Radium workspace initialized (optional, for some features)
Installationβ
Step 1: Install the Extensionβ
rad extension install radium-nvim
Or from a local directory:
rad extension install ./extensions/radium-nvim
Step 2: Load the Pluginβ
Add to your Neovim configuration (~/.config/nvim/init.lua or ~/.vimrc):
-- Load Radium plugin
require("radium")
Or if using a plugin manager like packer.nvim:
use({
"radium/radium-nvim",
config = function()
require("radium")
end
})
Commandsβ
:RadiumSendSelection
Sends the current visual selection to Radium for processing.
Usage:
- Select code in visual mode (
v,V, orCtrl-v) - Run
:RadiumSendSelection - Code is sent to Radium with full context:
- File path
- Language/filetype
- Selected code
- Surrounding lines (for context)
Configuration:
-- Set default agent (defaults to "code-agent")
vim.g.radium_default_agent = "code-agent"
:RadiumChatβ
Opens an interactive chat session with a Radium agent.
Usage:
:RadiumChat
This opens a split window with an integrated terminal running rad chat.
:RadiumApplyBlockβ
Applies the last agent-generated code block to the current buffer.
Usage:
- After receiving agent output from
:RadiumSendSelection - Run
:RadiumApplyBlock - A diff preview is shown
- Press
yto apply ornto cancel
Features:
- Shows diff preview before applying
- Handles multiple code blocks (prompts for selection)
- Can replace selection or insert at cursor
Configurationβ
Default Agentβ
vim.g.radium_default_agent = "code-agent"
Environment Variablesβ
The extension automatically sets these environment variables for hooks:
RADIUM_EDITOR_FILE_PATH- Full path to current fileRADIUM_EDITOR_LANGUAGE- Filetype/languageRADIUM_EDITOR_SELECTION- Selected codeRADIUM_EDITOR_SURROUNDING_LINES- Context around selection
Hook Integrationβ
The extension includes two hooks that are automatically registered:
BeforeTool Hook (editor-context)β
Injects editor context before tool execution:
- File path
- Language identifier
- Selected code
- Surrounding lines
AfterTool Hook (code-apply)β
Processes agent output:
- Extracts code blocks from markdown
- Structures output for editor application
- Adds metadata (language, line ranges)
Workflow Exampleβ
-
Select code:
Visual mode: v
Select function: jjj -
Send to Radium:
:RadiumSendSelection -
Review output:
- Agent response appears in split window
- Review the suggested changes
-
Apply changes:
:RadiumApplyBlock- Diff preview appears
- Press
yto apply ornto cancel
Troubleshootingβ
Commands not foundβ
Issue: :RadiumSendSelection command not available
Solution:
- Verify extension is installed:
rad extension list - Check plugin is loaded:
:lua print(require("radium")) - Reload Neovim configuration
CLI not foundβ
Issue: Error about rad command not found
Solution:
- Ensure Radium CLI is in PATH
- Test:
which radorrad --version - Restart Neovim after installing CLI
Context not injectedβ
Issue: Agent doesn't receive file context
Solution:
- Verify hooks are registered: Check extension installation
- Check environment variables are set
- Ensure file has a valid filetype set
Advanced Usageβ
Custom Agent Selectionβ
You can specify a different agent per command by modifying the command:
vim.api.nvim_create_user_command('RadiumRefactor', function()
vim.g.radium_default_agent = "refactor-agent"
require('radium.commands').send_selection()
end, {})
Integration with Other Pluginsβ
The extension stores agent output in buffer-local variables, making it accessible to other plugins or custom Lua code:
local output = vim.b.radium_last_output
-- Process output as needed
See Alsoβ
- Extension README (external repository)
- Architecture Documentation
- Troubleshooting Guide