From b81f80662bf526321e0ca76d9ade0e0fafcb3b89 Mon Sep 17 00:00:00 2001 From: Asep Komarudin <68836805+pojokcodeid@users.noreply.github.com> Date: Thu, 28 Mar 2024 18:37:12 +0700 Subject: [PATCH] Updated 7. Example Custom Plugins (markdown) --- 7.-Example-Custom-Plugins.md | 44 ++++++++++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) 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