Create fold.lua

This commit is contained in:
SamPosh 2023-04-20 13:43:14 +05:30 committed by GitHub
parent 733a92105d
commit dbe39c6b54
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 32 additions and 0 deletions

View File

@ -0,0 +1,32 @@
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>",
},
},
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,
},
}