reload_buffer
Refresh a Neovim buffer from disk after external file edits to ensure the editor displays current content.
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 main handler function that finds the Neovim instance, locates the buffer by path, and executes the Neovim command to reload it from disk using 'buffer ${bufnr} | edit!'.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:164-178 (schema)The tool schema definition including name, description, and input schema requiring a '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:274-284 (registration)The code in the CallToolRequest handler that routes calls to 'reload_buffer' to the reloadBuffer function and formats the response.if (name === "reload_buffer") { const result = await reloadBuffer(args.path); return { content: [ { type: "text", text: `Successfully reloaded buffer: ${result.path}`, }, ], }; }
- index.js:12-19 (registration)Import of the reloadBuffer handler function from lib/nvim-operations.js.getCurrentBuffer, listOpenBuffers, getBufferContent, updateBuffer, reloadBuffer, reloadAllBuffers, openFile, } from "./lib/nvim-operations.js";