๐ค Seamlessly integrate GeminiCLI with Neovim for an enhanced AI-assisted coding experience!
- ๐ฅ๏ธ Gemini CLI terminal integration within Neovim
- ๐ค Quick commands to add current buffer files (using
@syntax) - ๐ฉบ Send current buffer diagnostics to Gemini CLI
- ๐ Gemini CLI command selection UI with fuzzy search and input prompt
- ๐ Fully documented Lua API for programmatic interaction and custom integrations
- ๐ Auto-reload buffers on external changes (requires 'autoread')
-
:Gemini- Open interactive command menuCommands: health ๐ฉบ Check plugin health status toggle ๐๏ธ Toggle GeminiCLI terminal window command โจ๏ธ Show slash commands > diagnostics ๐ฉบ Send current buffer diagnostics add_file โ Add current file to session (using `@` syntax) ask โ Ask a question -
โก Direct command execution examples:
:Gemini health :Gemini add_file :Gemini send "Fix login validation"
๐ Python: Install gemini-cli
๐ System: Neovim >= 0.9.4
๐ Lua: folke/snacks.nvim,
Using lazy.nvim:
{
"marcinjahn/gemini-cli.nvim",
cmd = "Gemini",
-- Example key mappings for common actions:
keys = {
{ "<leader>a/", "<cmd>Gemini toggle<cr>", desc = "Toggle Gemini CLI" },
{ "<leader>aa", "<cmd>Gemini ask<cr>", desc = "Ask Gemini", mode = { "n", "v" } },
{ "<leader>af", "<cmd>Gemini add_file<cr>", desc = "Add File" },
},
dependencies = {
"folke/snacks.nvim",
},
config = true,
}After installing, run :GeminiCLI health to check if everything is set up correctly.
There is no need to call setup if you don't want to change the default options.
require("gemini_cli").setup({
-- Command that executes GeminiCLI
gemini_cmd = "gemini",
-- Command line arguments passed to gemini-cli
args = {
},
-- Automatically reload buffers changed by GeminiCLI (requires vim.o.autoread = true)
auto_reload = false,
-- snacks.picker.layout.Config configuration
picker_cfg = {
preset = "vscode",
},
-- Other snacks.terminal.Opts options
config = {
os = { editPreset = "nvim-remote" },
gui = { nerdFontsVersion = "3" },
},
win = {
wo = { winbar = "GeminiCLI" },
style = "gemini_cli",
position = "right",
},
})The plugin provides a structured API for programmatic integration. Access via require("gemini_cli").api
local api = require("gemini_cli").apiVerify plugin health status
api.health_check()Toggle GeminiCLI terminal window
api.toggle_terminal()Send raw text directly to GeminiCLI
api.send_to_terminal("Fix the login validation")Execute specific GeminiCLI command
api.send_command("/commit", "Add error handling")Add specific file to session
api.add_file("/src/utils.lua")``
Add current buffer's file (uses add_file internally)
vim.api.nvim_create_autocmd("BufWritePost", {
callback = function()
api.add_current_file()
end
})Send current buffer's diagnostics with an optional prompt
api.send_diagnostics_with_prompt()Interactive command selector with custom handling
api.open_command_picker(nil, function(picker, item)
if item.text == "/custom" then
-- Implement custom command handling
else
-- Default behavior
picker:close()
api.send_command(item.text)
end
end)This plugin is a Gemini CLI adaptation of nvim-aider.