diff --git a/7.-Example-Custom-Plugins.md b/7.-Example-Custom-Plugins.md index 71f53ce..5093366 100644 --- a/7.-Example-Custom-Plugins.md +++ b/7.-Example-Custom-Plugins.md @@ -2527,4 +2527,48 @@ return { end, }, } +``` +# Nvim-Ufo +```lua +return { + "kevinhwang91/nvim-ufo", + dependencies = { + "kevinhwang91/promise-async", + { + "luukvbaal/statuscol.nvim", + config = function() + local builtin = require("statuscol.builtin") + require("statuscol").setup({ + relculright = true, + segments = { + { text = { builtin.foldfunc }, click = "v:lua.ScFa" }, + { text = { "%s" }, click = "v:lua.ScSa" }, + { text = { builtin.lnumfunc, " " }, click = "v:lua.ScLa" }, + }, + }) + end, + }, + }, + event = "BufReadPost", + config = function() + vim.o.foldcolumn = "1" -- '0' is not bad + vim.o.foldlevel = 99 -- Using ufo provider need a large value, feel free to decrease the value + vim.o.foldlevelstart = 99 + vim.o.foldenable = true + vim.o.fillchars = [[eob: ,fold: ,foldopen:,foldsep: ,foldclose:]] + + -- these are "extra", change them as you like + vim.keymap.set("n", "zR", require("ufo").openAllFolds) + vim.keymap.set("n", "zM", require("ufo").closeAllFolds) + vim.cmd("highlight FoldColumn guifg=" .. vim.fn.synIDattr(vim.fn.synIDtrans(vim.fn.hlID("Comment")), "fg")) + -- Option 3: treesitter as a main provider instead + -- Only depend on `nvim-treesitter/queries/filetype/folds.scm`, + -- performance and stability are better than `foldmethod=nvim_treesitter#foldexpr()` + require("ufo").setup({ + provider_selector = function(bufnr, filetype, buftype) + return { "treesitter", "indent" } + end, + }) + end, +} ``` \ No newline at end of file