From abb6181701e25576fdfe00323840aba2102e2225 Mon Sep 17 00:00:00 2001 From: Hazem Krimi Date: Fri, 3 Apr 2026 13:06:54 +0100 Subject: [PATCH] feat: treesitter folding config autocommand --- lua/autocommands.lua | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/lua/autocommands.lua b/lua/autocommands.lua index b03ae8c..d2f89e8 100644 --- a/lua/autocommands.lua +++ b/lua/autocommands.lua @@ -57,3 +57,16 @@ vim.api.nvim_create_autocmd("BufWritePre", { end end, }) + +-- Folding config + +vim.api.nvim_create_autocmd("FileType", { + callback = function() + if require("nvim-treesitter.parsers").has_parser() then + vim.opt.foldmethod = "expr" + vim.opt.foldexpr = "nvim_treesitter#foldexpr()" + else + vim.opt.foldmethod = "syntax" + end + end, +})