Skip to main content
Glama

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
NameRequiredDescriptionDefault
pathYesThe file path of the buffer to reload

Implementation Reference

  • 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}`); }
  • 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";
  • 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}`, }, ], }; }

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/laktek/nvim-mcp-server'

If you have feedback or need assistance with the MCP directory API, please join our Discord server