Skip to main content
Glama

vim_fold

Manage code folding in Neovim by creating, opening, closing, toggling, or deleting folds. Specify start and end lines for precise fold creation, enhancing code readability and navigation.

Instructions

Manage code folding: create, open, close, and toggle folds

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
actionYesFolding action to perform
endLineNoEnd line for creating fold (required for create)
startLineNoStart line for creating fold (required for create)

Implementation Reference

  • Core handler implementation for vim_fold tool. Executes specific Neovim folding commands (zf, zo, zc, za, zR, zM, zd) based on the action parameter, with validation for manual fold creation.
    public async manageFold(action: string, startLine?: number, endLine?: number): Promise<string> { try { const nvim = await this.connect(); switch (action) { case 'create': if (startLine === undefined || endLine === undefined) { throw new NeovimValidationError('Start line and end line are required for creating folds'); } await nvim.command(`${startLine},${endLine}fold`); return `Created fold from line ${startLine} to ${endLine}`; case 'open': await nvim.input('zo'); return 'Opened fold at cursor'; case 'close': await nvim.input('zc'); return 'Closed fold at cursor'; case 'toggle': await nvim.input('za'); return 'Toggled fold at cursor'; case 'openall': await nvim.command('normal! zR'); return 'Opened all folds'; case 'closeall': await nvim.command('normal! zM'); return 'Closed all folds'; case 'delete': await nvim.input('zd'); return 'Deleted fold at cursor'; default: throw new NeovimValidationError(`Unknown fold action: ${action}`); } } catch (error) { if (error instanceof NeovimValidationError) { throw error; } console.error('Error managing fold:', error); throw new NeovimCommandError(`fold ${action}`, error instanceof Error ? error.message : 'Unknown error'); } }
  • src/index.ts:538-563 (registration)
    MCP tool registration for 'vim_fold', including description, input schema, and thin wrapper handler that delegates to NeovimManager.manageFold.
    server.tool( "vim_fold", "Manage code folding: create, open, close, and toggle folds", { action: z.enum(["create", "open", "close", "toggle", "openall", "closeall", "delete"]).describe("Folding action to perform"), startLine: z.number().optional().describe("Start line for creating fold (required for create)"), endLine: z.number().optional().describe("End line for creating fold (required for create)") }, async ({ action, startLine, endLine }) => { try { const result = await neovimManager.manageFold(action, startLine, endLine); return { content: [{ type: "text", text: result }] }; } catch (error) { return { content: [{ type: "text", text: error instanceof Error ? error.message : 'Error managing fold' }] }; } }
  • Zod input schema defining parameters for the vim_fold tool: action (enum of fold operations), optional startLine and endLine for manual folds.
    { action: z.enum(["create", "open", "close", "toggle", "openall", "closeall", "delete"]).describe("Folding action to perform"), startLine: z.number().optional().describe("Start line for creating fold (required for create)"), endLine: z.number().optional().describe("End line for creating fold (required for create)")

Other Tools

Related Tools

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/bigcodegen/mcp-neovim-server'

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