From dbe39c6b54a74f3f6f77c9cb966e484b013ce44c Mon Sep 17 00:00:00 2001 From: SamPosh Date: Thu, 20 Apr 2023 13:43:14 +0530 Subject: [PATCH] Create fold.lua --- lua/custom/plugins/fold.lua | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 lua/custom/plugins/fold.lua diff --git a/lua/custom/plugins/fold.lua b/lua/custom/plugins/fold.lua new file mode 100644 index 00000000..6d15fb14 --- /dev/null +++ b/lua/custom/plugins/fold.lua @@ -0,0 +1,32 @@ +return { + "kevinhwang91/nvim-ufo", + event = { "User AstroFile", "InsertEnter" }, + dependencies = { "kevinhwang91/promise-async" }, + opts = { + preview = { + mappings = { + scrollB = "", + scrollF = "", + scrollU = "", + scrollD = "", + }, + }, + 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, + }, + }