From 1105b3fee91ebaacb34720e96fd7fef7ba4864cc Mon Sep 17 00:00:00 2001 From: Thomas Voss Date: Tue, 12 Sep 2023 23:09:50 +0200 Subject: nvim: Enable tree-sitter code folding --- .config/nvim/lua/mango/set.lua | 26 ++++++++++++++++---------- 1 file changed, 16 insertions(+), 10 deletions(-) (limited to '.config/nvim/lua') diff --git a/.config/nvim/lua/mango/set.lua b/.config/nvim/lua/mango/set.lua index 0ef61ff..d082916 100644 --- a/.config/nvim/lua/mango/set.lua +++ b/.config/nvim/lua/mango/set.lua @@ -2,6 +2,8 @@ local lib = require('mango.lib') local api = vim.api local opt = vim.opt +local augroup = api.nvim_create_augroup('Mango', { clear = true }) + opt.nu = true opt.relativenumber = true @@ -34,13 +36,17 @@ opt.splitright = true opt.splitbelow = true -- Disable auto commenting -local group = api.nvim_create_augroup('Mango', { clear = true }) -api.nvim_create_autocmd( - 'BufEnter', - { - callback = function() - opt.formatoptions:remove({'c', 'r', 'o'}) - end, - group = group, - } -) +api.nvim_create_autocmd('BufEnter', { + callback = function() + opt.formatoptions:remove({'c', 'r', 'o'}) + end, + group = augroup, +}) + +opt.foldmethod = 'expr' +opt.foldexpr = 'nvim_treesitter#foldexpr()' + +api.nvim_create_autocmd('BufWinEnter', { + command = 'normal zR', + group = augroup, +}) -- cgit v1.2.3