From 19926d284862b5e58f29e73b71ec532ac29c54ba Mon Sep 17 00:00:00 2001 From: Folke Lemaitre Date: Tue, 3 Oct 2023 08:02:10 +0200 Subject: [PATCH] feat(options): enabled treesitter folding and foldtext when available --- lua/lazyvim/config/options.lua | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/lua/lazyvim/config/options.lua b/lua/lazyvim/config/options.lua index cee2bc26..2262dbff 100644 --- a/lua/lazyvim/config/options.lua +++ b/lua/lazyvim/config/options.lua @@ -51,5 +51,17 @@ if vim.fn.has("nvim-0.10") == 1 then opt.smoothscroll = true end +-- Folding +vim.opt.foldlevel = 99 +if vim.treesitter.foldexpr then + vim.opt.foldmethod = "expr" + vim.opt.foldexpr = "v:lua.vim.treesitter.foldexpr()" +else + vim.opt.foldmethod = "indent" +end +if vim.treesitter.foldtext then + vim.opt.foldtext = "v:lua.vim.treesitter.foldtext()" +end + -- Fix markdown indentation settings vim.g.markdown_recommended_style = 0