setup ufo for code folding

This commit is contained in:
lobneroO 2024-01-21 08:51:02 +01:00
parent 8baa1144ab
commit ebf58a549f
1 changed files with 17 additions and 18 deletions

View File

@ -5,6 +5,12 @@ return {
event = "BufRead", event = "BufRead",
dependencies = { "kevinhwang91/promise-async" }, dependencies = { "kevinhwang91/promise-async" },
config = function() config = function()
-- default settings to enable
vim.o.foldcolumn = "1"
vim.o.foldlevel = 99
vim.o.foldlevelstart = 99
vim.o.foldenable = true
-- setup folding source: first lsp, then indent as fallback -- setup folding source: first lsp, then indent as fallback
require("ufo").setup({ require("ufo").setup({
provider_selector = function(bufnr, filetype, buftype) provider_selector = function(bufnr, filetype, buftype)
@ -12,16 +18,9 @@ return {
end end
}) })
-- default settings to enable
vim.o.foldcolumn = '1'
vim.o.foldlevel = 99
vim.o.foldlevelstart = 99
vim.o.foldenable = true
-- remap keys for "fold all" and "unfold all" -- remap keys for "fold all" and "unfold all"
vim.keymap.set('n', 'zR', require('ufo').openAllFolds, { desc = "Open all folds" }) vim.keymap.set('n', 'zR', require('ufo').openAllFolds, { desc = "Open all folds" })
vim.keymap.set('n', 'zM', require('ufo').closeAllFolds, { desc = "Close all folds" }) vim.keymap.set('n', 'zM', require('ufo').closeAllFolds, { desc = "Close all folds" })
end,
end
} }