-
Notifications
You must be signed in to change notification settings - Fork 49
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
FR: Simplify provider_selector
by accepting more than one fallback
#256
Comments
What's the issue with the function in config? |
It's unnecessarily complicated. The third person I recommended nvim-ufo too was confused about that particular setting. Assuming the user wants to use LSP as folding provider, and treesitter as fallback, and then indent as fallback for when there is neither LSP nor treesitter available – which in my view is the best way to configure ufo – their config would have to look like this: provider_selector = function(_, ft, _)
local lspWithOutFolding = { "markdown", "zsh", "css", "html", "python", "json" }
if vim.tbl_contains(lspWithOutFolding, ft) then return { "treesitter", "indent" } end
return { "lsp", "indent" }
end, While with my suggestions, their config can simply be: provider_selector = { "lsp", "treesitter", "indent" }, |
Will make the document of config complicated and make users understand the work mechanism difficulty. Even though the setup doesn't look compact, the users know how ufo to select the provider. The filetype is mapped to the provider clearly. If the filetype the users don't read frequently, they don't need to configure it, the |
Lines 26 to 57 in c96bb3b
|
Well, in my view, it is exactly the opposite: the current method of configuring felt overly complex to the colleagues I helped set up nvim-ufo. But if you view it differently, I guess there is no point in arguing. Nonetheless, thanks for the maintaining this plugin |
@chrisgrieser I also was looking for the ability to specify multiple fallbacks and after coming across this issue I decided to implement it myself. You can check out my fork if you want to. But I did not (yet) add the ability to specify the providers as a table instead of a function. @kevinhwang91, if you change your mind about this feature, I’d be happy to submit a PR here. And also from my side a big thank you for creating and maintaining this awesome plugin — I really appreciate it! |
Should leave this issue open to listen to the sound. |
Chris' solution is simpler and straightforward especially for new users. In my opinion, it should be the default behavior. I don't think most users want to or should know the inner workings of I spent way too much time yesterday trying to setup This Thanks for this great plugin. |
Feature description
provider_selector
right now only accepts a return value with two strings. However, I generally would find it useful to define more fallbacks. For instance, I prefer LSP as main provider, then treesitter as first fallback, and then indent if there is neither LSP nor treesitter available as fallback provider.Right now, defining such a behavior requires a small function with some conditionals, even though for most users, a much simpler config would suffice.
Describe the solution you'd like
Make
provider_selector
accept more fallbacks, for example:Additional context
No response
The text was updated successfully, but these errors were encountered: