nvim-cmp
nvim-cmp copied to clipboard
feat: Refactor compare.scopes
On nvim-treesitter main, some of the methods used in cmp's compare.scopes now error instead of returning an empty table when no tree-sitter parser exists (specifically, locals.get_*). This implements a basic fix.
~~Leaving it as a draft because:~~
- Not sure on the best way to track whether a buffer has tree-sitter parsing.
- Maybe track the buffers in
compare.scopesinstead ofvim.b? - Would it be better to not track buffers and just
pcallthe affectedlocals.get_*methods?
- Maybe track the buffers in
- Not sure about modifying autocmd helpers to include the lua callback table.
Edit: This PR has also turned into an overhaul of compare.scopes:
- Improves performance a bit by only looping over
definitionsonce perupdate() - Clears previous results on each
update, leading to more expected sorting (previously, nothing ever got removed or modified once it was put into thescopes_map).
edit2: I can also revert the renaming of the variables if you'd like, I just did it out of my preference when I was changing the function around