diff --git a/init.lua b/init.lua index e7f1eec4..94d0be72 100644 --- a/init.lua +++ b/init.lua @@ -229,7 +229,7 @@ require('lazy').setup({ -- Uncomment the following line and add your plugins to `lua/custom/plugins/*.lua` to get going. -- -- For additional information see: https://github.com/folke/lazy.nvim#-structuring-your-plugins - -- { import = 'custom.plugins' }, + { import = 'custom.plugins' }, }, {}) -- [[ Setting options ]] diff --git a/lua/custom/plugins/ufo.lua b/lua/custom/plugins/ufo.lua new file mode 100644 index 00000000..c4561593 --- /dev/null +++ b/lua/custom/plugins/ufo.lua @@ -0,0 +1,27 @@ +-- install plugin for code folding + +return { + "kevinhwang91/nvim-ufo", + event = "BufRead", + dependencies = { "kevinhwang91/promise-async" }, + config = function() + -- setup folding source: first lsp, then indent as fallback + require("ufo").setup({ + provider_selector = function(bufnr, filetype, buftype) + return { 'lsp', 'indent' } + 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" + vim.keymap.set('n', 'zR', require('ufo').openAllFolds, { desc = "Open all folds" }) + vim.keymap.set('n', 'zM', require('ufo').closeAllFolds, { desc = "Close all folds" }) + + end +} +