40 lines
975 B
Lua
40 lines
975 B
Lua
local M = { "nvim-treesitter/nvim-treesitter" }
|
|
|
|
M.event = { "InsertEnter" }
|
|
|
|
M.dependencies = { "kevinhwang91/promise-async" }
|
|
|
|
M.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,
|
|
}
|
|
|
|
return M
|