reload_buffer
Refresh a Neovim buffer from disk after external file edits to ensure content synchronization.
Instructions
Reload a buffer from disk. Use this after editing a file externally to refresh the buffer in Neovim.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| path | Yes | The file path of the buffer to reload |
Implementation Reference
- lib/nvim-operations.js:181-204 (handler)The core handler function that reloads the specified buffer in Neovim by switching to it and executing 'edit!' to reload from disk.export async function reloadBuffer(bufferPath) { const instances = await getNvimInstancesInCwd(); for (const { nvim } of instances) { try { const buffers = await nvim.buffers; for (const buf of buffers) { const name = await buf.name; if (name === bufferPath) { // Use nvim command to reload the buffer from disk const bufnr = buf.id; await nvim.command(`buffer ${bufnr} | edit!`); return { success: true, path: bufferPath }; } } } catch (error) { console.error("Error reloading buffer:", error.message); } } throw new Error(`Buffer not found: ${bufferPath}`); }
- index.js:163-177 (schema)Input schema definition for the reload_buffer tool, specifying a required 'path' parameter.{ name: "reload_buffer", description: "Reload a buffer from disk. Use this after editing a file externally to refresh the buffer in Neovim.", inputSchema: { type: "object", properties: { path: { type: "string", description: "The file path of the buffer to reload", }, }, required: ["path"], }, },
- index.js:12-19 (registration)Import statement registering the reloadBuffer handler function for use in the MCP server.getCurrentBuffer, listOpenBuffers, getBufferContent, updateBuffer, reloadBuffer, reloadAllBuffers, } from "./lib/nvim-operations.js";
- index.js:257-267 (helper)Dispatcher in the CallToolRequestHandler that invokes the reloadBuffer function with the provided path argument.if (name === "reload_buffer") { const result = await reloadBuffer(args.path); return { content: [ { type: "text", text: `Successfully reloaded buffer: ${result.path}`, }, ], }; }