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

Use LSP provider if available or tree-sitter as fallback #63

Closed gbrlsnchs closed 2 years ago

gbrlsnchs commented 2 years ago

Feature description

I've seen in the examples that you can either use LSP plus regular fallback or tree-sitter plus regular fallback, but can you use LSP when available, then tree-sitter as the fallback? Some filetypes don't have such LSP support but do have tree-sitter support.

Describe the solution you'd like

Use LSP provider if available, otherwise fall back to tree-sitter provider and only if none is available, then fall back to the default one.

Additional context

No response

kevinhwang91 commented 2 years ago

TLDR; https://github.com/kevinhwang91/nvim-ufo/blob/480209aae4a032988761fe1d51c8f47a44168589/doc/example.lua#L23-L52

main provider may throw UfoFallbackException error to wake up fallback provider. If you want to use lsp->treesitter->indent chain, you must add the customized provider yourself. ufo has given an example.

Never consider adding this example to README because I haven't seen a fallback chain for a client to request servers that I think it is fragile.

edit: example is changed