fix(nvim): elegant fold configuration

This commit is contained in:
László Párkányi
2026-01-06 15:09:17 +01:00
parent 31c2f6a869
commit 90aa0c5868

View File

@@ -6,8 +6,27 @@ local autocmd = vim.api.nvim_create_autocmd
-- command = "tabdo wincmd =",
-- })
-- Auto unfold all when entering a buffer
-- autocmd("BufWinEnter", { pattern = "*", command = "silent! :%foldopen!" })
autocmd({ "FileType" }, {
callback = function()
-- check if treesitter has parser
if require("nvim-treesitter.parsers").has_parser() then
-- use treesitter folding
vim.opt.foldmethod = "expr"
vim.opt.foldexpr = "nvim_treesitter#foldexpr()"
else
-- use alternative foldmethod
vim.opt.foldmethod = "syntax"
end
end,
})
-- disable folding on startup
vim.opt.foldenable = false
-- disable folding on loading
vim.opt.foldlevel = 20
-- Hyrplang filetype
vim.filetype.add({