From 4fcc6399a5ae61530d03c83cf089a8015ae11024 Mon Sep 17 00:00:00 2001 From: SamPosh Date: Thu, 20 Apr 2023 14:11:03 +0530 Subject: [PATCH] Folding is added as per lazy config --- lua/custom/plugins/fold.lua | 59 +++++++++++++++++++------------------ 1 file changed, 31 insertions(+), 28 deletions(-) diff --git a/lua/custom/plugins/fold.lua b/lua/custom/plugins/fold.lua index 6d15fb14..19042b29 100644 --- a/lua/custom/plugins/fold.lua +++ b/lua/custom/plugins/fold.lua @@ -1,32 +1,35 @@ return { + { "kevinhwang91/nvim-ufo", - event = { "User AstroFile", "InsertEnter" }, - dependencies = { "kevinhwang91/promise-async" }, - opts = { - preview = { - mappings = { - scrollB = "", - scrollF = "", - scrollU = "", - scrollD = "", - }, + event = "BufRead", + dependencies = { + { "kevinhwang91/promise-async" }, + { + "luukvbaal/statuscol.nvim", + config = function() + local builtin = require("statuscol.builtin") + require("statuscol").setup({ + -- foldfunc = "builtin", + -- setopt = true, + relculright = true, + segments = { + { text = { builtin.foldfunc }, click = "v:lua.ScFa" }, + { text = { "%s" }, click = "v:lua.ScSa" }, + { text = { builtin.lnumfunc, " " }, click = "v:lua.ScLa" }, + }, + }) + end, }, - provider_selector = function(_, filetype, buftype) - local function handleFallbackException(bufnr, err, providerName) - if type(err) == "string" and err:match "UfoFallbackException" then - return require("ufo").getFolds(bufnr, providerName) - else - return require("promise").reject(err) - end - end - - return (filetype == "" or buftype == "nofile") and "indent" -- only use indent until a file is opened - or function(bufnr) - return require("ufo") - .getFolds(bufnr, "lsp") - :catch(function(err) return handleFallbackException(bufnr, err, "treesitter") end) - :catch(function(err) return handleFallbackException(bufnr, err, "indent") end) - end - end, }, - } + config = function() + -- Fold options + vim.o.fillchars = [[eob: ,fold: ,foldopen:,foldsep: ,foldclose:]] + 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 + + require("ufo").setup() + end, + }, +}