Closed kevinhwang91 closed 2 years ago
I would love to have treesitter, because I don't have a language server for all languages, but usually a tree parser. Anyway, it would be amazing if it would be possible to have something like a provider priority list. So I can say: use LSP if available, else fall back to treesitter if available, else use indent level. I guess I can write a custom provider function that does that. But would be amazing if I could just configure a list of providers. What do you think? 🙂
treesitter provider may come this weekend.
A list of providers isn't useful for most users. In reality world, a client ask for multiple services as fallbacks, which means its software system is fragile.
lsp
+ indent
is extremely high perf and can be applied to many filetypes, I don't think treesitter provider can take a place for them (not stable and high perf enough), but it should give the choice for the users.
I'm using treesitter folding since a long time already and can't complain. And definitely not about the performance. 🤷♂️ I also don't "agree" with these kind of features as part of language server. But that is my personal opinion. I like your plugin because of the syntax highlighting it provides. 🤗
I also don't "agree" with these kind of features as part of language server.
No conflict, if treesitter provider is done, you can set it {'treesitter', 'indent'}
or just 'treesitter'
. Disable all the provider the plug provided by value ''
if you are not satisfied with all of the imp of ufo and use set foldexpr=nvim_treesitter#foldexpr()
.
The latter is what I have right now. 😬 Thank you very much for your hard work. Looking forward to finally use your plugin. 🙃
should work, this feature is easy and low priority, I am lazy to write document for now. If the doc is done, will close this issue. (writing doc is hardest part for this feature)
local ftMap = {
vim = 'indent',
python = {'indent'},
git = ''
}
require('ufo').setup({
provider_selector = function(bufnr, filetype)
-- return a string type use internal providers
-- return a string in a table like a string type
-- return empty string '' will disable any providers
-- return `nil` will use default value {'lsp', 'indent'}
return ftMap[filetype] or {'treesitter', 'indent'}
end
})
UfoInspect
command checks the provider info.
The STW(stop the world) perf: lsp
> indent
> treesitter
> nvim-treesitter expr
.
Why perf of treesiter
provider is better than nvim-treesitter expr
?
vim.tbl_extend()
inside iter.foldmethod=expr
is out of control, undo
action will fire the expr frequently.If you want to reduce the STW, converting treesitter
provider to null-ls foldingrange
service should as well as lsp
provider, the codebase of treesitter
provider is simple.
Great. Thank you very much!
doc has been updated.
Feature description
Someone loves treesitter, but I think is fragile for all languages and low perf compared with
lsp
andindent
providers.Low priority for this feature.
Describe the solution you'd like
borrow code from nvim-treesitter and transform the
expr
format to lsp foldingrange format formanual
.Additional context
No response