New
Apps 6,363Makers 6,342This week 13
Promote your app−30%
Custom Code Folding for Zed screenshot 1
5views in
the last 30 days

Custom Code Folding for Zed

Zed extension that adds configurable code folding regions via comment markers

Built with Claude Code/Zed

by tomchor · Unclaimed · from USUnited States · added Oct 29, 2026
no ratings0 comments

Custom Code Folding for Zed

A Zed extension that adds configurable code folding via custom comment markers.

Zed doesn't natively support custom foldable regions (like VS Code's #region/#endregion). This extension provides an LSP server that implements textDocument/foldingRange, letting you define fold regions with comment markers like # +++ Section / # ---.

The extension registers for 40+ languages. See extension.toml for the full list and please feel free to open a pull request to add support for more languages.

Regions can be nested:

# +++ Outer
  # +++ Inner
  code
  # ---
# ---

Setup

1. Install the extension

Search for "Custom Code Folding" in Zed's extension panel, or install from the command palette.

For local development:

cargo install --path crates/custom-code-folding-server

Then use "zed: install dev extension" from the command palette and select this repo.

2. Enable LSP folding ranges

Add to your Zed settings.json:

{
  "document_folding_ranges": "on"
}

Important: This replaces Zed's built-in indent/tree-sitter folding with LSP-provided folding ranges. Since Zed merges ranges from all active language servers, structural folds (functions, classes, etc.) are preserved as long as your primary language server provides them (most do: pyright, rust-analyzer, gopls, typescript-language-server, etc.).

Default Fold Patterns

Two patterns are built in:

plus-minus

# +++ Section Name
code here
# ---

Works with # and // comment styles.

region

// #region Section Name
code here
// #endregion

Works with //, #, and /* */ comment styles.

Custom Patterns

You can add your own custom patterns via settings.json by using Regex patterns:

{
  "lsp": {
    "custom-code-folding": {
      "initialization_options": {
        // Set false to disable built-in patterns
        "include_defaults": true,

        // Additional patterns (appended to defaults)
        "patterns": [
          {
            "name": "begin-end",
            "start": "^\\s*//\\s*BEGIN\\s+(?P<label>.*?)\\s*$",
            "end": "^\\s*//\\s*END"
          }
        ]
      }
    }
  }
}
  • start: Regex matching the opening marker. Use (?P<label>...) to capture a label shown when folded.
  • end: Regex matching the closing marker.
  • include_defaults: When true (default), your patterns are added alongside the built-in ones. Set false to use only your custom patterns.

Credits

Originally created by Ali Ramadhan as ali-ramadhan/zed-custom-code-folding, in response to Zed discussion #41167. This fork revives the extension to publish it to the Zed extension registry.

Description taken from the repository README.

Ratings

–
0 ratings
5 0
4 0
3 0
2 0
1 0

Rate this app

Sign in to rate

Comments 0

Sign in to comment

No comments yet.

Related apps

#zed-extension · #code-folding · #lsp