mirror of
https://github.com/nicolas-martin/region-folding.nvim.git
synced 2026-11-07 21:53:55 +03:00
No description
- Lua 100%
| Filename | Latest commit message | Latest commit date |
|---|---|---|
| assets | ||
| lua/region-folding | ||
| tests | ||
| .gitignore | ||
| LICENSE | ||
| README.md | ||
region-folding.nvim
A minimal Neovim plugin for custom code folding using region markers. Automatically folds regions while preserving treesitter folding for functions and other code structures.
Features
- Custom region folding with
#region/#endregionmarkers - Smart fold text showing region names and function names
- Treesitter compatibility - works alongside existing fold methods
- Multi-language support - 20+ languages out of the box
- Intelligent navigation with
zj/zkbetween all fold types - Auto-fold regions while keeping functions visible by default
Installation
Lazy.nvim:
{
"nicolas-martin/region-folding.nvim",
event = { "BufReadPost", "BufNewFile" },
opts = {} -- Use defaults
}
With custom options:
{
"nicolas-martin/region-folding.nvim",
event = { "BufReadPost", "BufNewFile" },
opts = {
region_text = { start = "#region", ending = "#endregion" },
fold_indicator = "▼"
}
}
Configuration
Required fold settings in your init.lua or options.lua:
-- Enable treesitter folding (required for function folding)
vim.opt.foldmethod = "expr"
vim.opt.foldexpr = "nvim_treesitter#foldexpr()"
vim.opt.foldenable = true
vim.opt.foldlevel = 99
vim.opt.foldlevelstart = 99
Fold Commands
| Command | Description |
|---|---|
za |
Toggle fold at cursor |
zj / zk |
Navigate to next/previous fold |
zR |
Open all folds |
zM |
Close all folds |
Troubleshooting
Functions not folding, only regions work:
- Ensure treesitter folding is enabled (see Configuration section above)
- Install language parsers:
:TSInstall <language> - Verify treesitter is working:
:checkhealth nvim-treesitter
No folding at all:
- Check fold settings:
:set foldmethod? foldexpr? - Verify plugin loaded:
:lua print(require('region-folding'))
