How to install nvim-ufo in LazyVim to enable foldable code blocks
A feature that I've found myself missing since making the switch to Vim as my editor of choice is the ability to easily fold and expand code blocks.
I know this functionality is included in Neovim, but I couldn't understand the native implementation enough to use it effectively and started searching for any plugins that gave me this ability.
I'm not the only one who's had this struggle (example Reddit thread here), and lots of folks point to nvim-ufo
as the best plugin for this.
For those looking for a quick copy/paste configuration (LazyVim edition):
return {
"kevinhwang91/nvim-ufo",
dependencies = {
{ "kevinhwang91/promise-async" },
},
}
Once you've reloaded your Vim config, try entering zc
and zo
within a function, code block, etc. to close and open a single fold in your code to confirm everything is working.
I haven't found that I've needed the other configuration mentioned in the 'minimal configuration' section of the project's README besides the keymappings and options such as foldlevel
, foldlevelstart
, etc.
Like what you've read?
Subscribe to receive the latest updates in your inbox.