You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Given some TreeSitter nodes that classify a lot of things similarly, such as the example below with Elixir with both alias ... and def my_function being parsed as "call" nodes, it doesn't look like tssorter will allow me to select nodes that satisfy a list of conditions and will grab too many unrelated siblings in the AST to sort. In my case, I'm trying to only sort the alias lines, not the def lines.
There's a couple solutions I can think of, LMK what you think:
Allow :TSSort to accept a range to sort within, so I can visually select the block of aliases, and TSSorter only regards those.
Allow config to specify conditions on the node somehow. In Scheme,
my config, using lazy.nvim:
{ 'mtrajano/tssorter.nvim',
-- latest stable version, use `main` to keep up with the latest changesversion='*',
config=function()
localtssorter=require('tssorter')
tssorter.setup({
sortables= {
elixir= {
alias= {
node='call',
ordinal='arguments'
},
alias_group= {
node='alias'
}
}
}
})
The text was updated successfully, but these errors were encountered:
Interesting that those two types of nodes are considered call nodes in Elixer. To me it seems like it should be two different types of named nodes, but that's besides the point, and I'm not an Elixer dev so I can't say for sure why it was done that way. I do have the ability to sort nodes in a visual selection/range as one of the things on my todo and it's something I'm going to be working on soon. That should resolve the problem you're having. I can ping here once that change is out.
I think your other suggestion to have the ability to configure some sort of condition/filter for whether a node should be considered sortable is also interesting but I'm afraid of adding unnecessary complexity. For now the ability to sort a range should do the trick and fix the issue you are having. It could be something worth exploring in the future, would just need to see some more use cases where it's needed.
Given some TreeSitter nodes that classify a lot of things similarly, such as the example below with Elixir with both
alias ...
anddef my_function
being parsed as "call" nodes, it doesn't look like tssorter will allow me to select nodes that satisfy a list of conditions and will grab too many unrelated siblings in the AST to sort. In my case, I'm trying to only sort thealias
lines, not thedef
lines.There's a couple solutions I can think of, LMK what you think:
:TSSort
to accept a range to sort within, so I can visually select the block of aliases, and TSSorter only regards those.my config, using lazy.nvim:
The text was updated successfully, but these errors were encountered: