Folding is added as per lazy config

This commit is contained in:
SamPosh 2023-04-20 14:11:03 +05:30 committed by GitHub
parent b03ea9dd9b
commit 4fcc6399a5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 31 additions and 28 deletions

View File

@ -1,32 +1,35 @@
return {
{
"kevinhwang91/nvim-ufo",
event = { "User AstroFile", "InsertEnter" },
dependencies = { "kevinhwang91/promise-async" },
opts = {
preview = {
mappings = {
scrollB = "<C-b>",
scrollF = "<C-f>",
scrollU = "<C-u>",
scrollD = "<C-d>",
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
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
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
require("ufo").setup()
end,
},
}