kevinhwang91 / nvim-ufo

Not UFO in the sky, but an ultra fold in Neovim.
BSD 3-Clause "New" or "Revised" License
2.23k stars 44 forks source link

error showing while opening uncommon file extensions #61

Closed edward-s closed 2 years ago

edward-s commented 2 years ago

Neovim version (nvim -v | head -n1)

0.8 nightly

Operating system/version

macOS 12

How to reproduce the issue

Plugin and fold works great for common file types (javascript, json, html etc)

but, on opening a file of a uncommon/unknown extension (i.e: .huskyrc, .dockerignore), it immediately errors out with the message below

Expected behavior

I don't expect the fold to work on these files, but at least the plugin should not throw error

Actual behavior

Error executing vim.schedule lua callback: UnhandledPromiseRejection with the reason:
...re/nvim/site/pack/packer/start/nvim-ufo/lua/ufo/fold.lua:112: ...ck/packer/start/nvim-ufo/lua/ufo/provider/treesitter.lua:95: UfoFallbackException
stack traceback:
        ...re/nvim/site/pack/packer/start/nvim-ufo/lua/ufo/fold.lua:45: in function <Anonymous:26>
kevinhwang91 commented 2 years ago

can't reproduce, please provide min.lua

kevinhwang91 commented 2 years ago

I guess you set

        provider_selector = function(bufnr, filetype, buftype)
            return {'lsp', 'treesitter'}
        end,

provider_selector return main and fallback provider, not a provider chain.

lsp and treesitter are main providers, fallback provider is only indent for now.

edward-s commented 2 years ago
provider_selector = function()
    return { "treesitter", "indent" }
end

works for me, thanks!