acpear.nvim

January 10, 2026 ยท View on GitHub

Acpear is a Neovim plugin that implements the Agent Client Protocol (ACP), turning Neovim into a powerful client for AI coding agents like OpenCode, Claude Code, and Gemini CLI.

Features

  • Buffer as UI: Chat with agents in a dedicated buffer.
  • Structure: Custom <user-msg> and <agent-response> blocks with Markdown highlighting.
  • Tools: Exposes Neovim features (Read Buffer, Diagnostics) to the agent.
  • Diff Integration: (Coming Soon) Review agent edits via standard Vim diffs.

Installation

-- lazy.nvim
{
    "Eric-Song-Nop/acpear.nvim",
    config = function()
        require("acpear").setup({
            agents = {
                opencode = { cmd = "opencode", args = {"start"} },
                -- Add your custom agents here
            }
        })
    end
}

Usage

  1. Start a session:

    :AcpearStart opencode
    
  2. Type your message inside the <user-msg> block.

  3. Press <CR> (Enter) in Normal mode to submit.

  4. The agent will respond, and a new user block will be created.

Integration

Key Mappings

The plugin uses <CR> in Normal mode on <user-msg> blocks to submit messages. You can customize this:

vim.api.nvim_buf_set_keymap(0, "n", "<leader>as", "", {
    callback = function()
        require("acpear").submit()
    end,
    desc = "Submit message to agent"
})

Telescope Integration

Add to your Telescope config to browse acpear buffers:

local telescope = require("telescope")
telescope.setup({
    extensions = {
        -- Your other extensions
    }
})

-- Show only acpear chat buffers
vim.keymap.set("n", "<leader>ac", function()
    require("telescope.builtin").buffers({
        type = "acpear"
    })
end, { desc = "Acpear buffers" })

Status Line Integration

Display the current agent status in your status line:

-- For lualine
local function acpear_status()
    local bufnr = vim.api.nvim_get_current_buf()
    local ft = vim.api.nvim_get_option_value("filetype", { buf = bufnr })
    if ft == "acpear" then
        return "ACP: " .. (vim.b.acpear_agent or "inactive")
    end
    return ""
end

require("lualine").setup({
    sections = {
        lualine_a = { "mode", acpear_status }
    }
})

Command Palette Integration

Add acpear commands to which-key or similar plugins:

-- which-key.nvim
local wk = require("which-key")
wk.register({
    a = {
        name = "Acpear",
        s = { ":AcpearStart opencode<CR>", "Start opencode session" },
        c = { ":AcpearStart claude<CR>", "Start claude session" },
        q = { ":bd<CR>", "Close acpear buffer" }
    }
}, { prefix = "<leader>" })

Requirements

  • Neovim 0.10+
  • An ACP-compatible agent installed on your system (e.g., opencode).

Tree-sitter Parser Installation

The plugin includes the tree-sitter parser source code in the tree-sitter-acpear/ directory. Install it with nvim-treesitter:

:TSInstall acpear

If the parser is not available, you need to register it first. Add this to your Neovim config:

vim.api.nvim_create_autocmd("User", {
  pattern = "TSUpdate",
  callback = function()
    local paths = vim.api.nvim_get_runtime_file("tree-sitter-acpear", false)
    local parser_path = paths[1] or error("tree-sitter-acpear directory not found")
    local parsers = require("nvim-treesitter.parsers")
    parsers.acpear = {
      install_info = {
        path = parser_path,
        files = { "src/parser.c", "src/scanner.c" },
      },
    }
  end,
})

Then run:

:TSInstall acpear