Neovim for Beginners — Code Folding
Learn the basics of folding and how to configure treesitter and LSP-based code folding.
In this article, we will learn the basics of folding and how to configure treesitter and LSP-based code folding.
This article is part of the Neovim for Beginners series.
The Neovim configuration files can be found in this repository.
Getting Started
The fastest way to understand folding is to spend a few minutes going through the Vim manual (:h usr_28.txt
). We will only go through the basics here.
Fold Method
The foldmethod
option (:h 'foldmethod’
) defines the kind of folding used for the current window. Possible values for this option are
manual
(:h fold-manual
) — Folds are created manually.indent
(:h fold-indent
) — Lines with equal indent form a fold.expr
(:h fold-expr
) —foldexpr
gives the fold level of a line.marker
(:h fold-marker
) — Markers are used to specify folds.