Skip to content
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

feat: Refactor compare.scopes #2007

Open
wants to merge 9 commits into
base: main
Choose a base branch
from

Conversation

pynappo
Copy link
Contributor

@pynappo pynappo commented Aug 2, 2024

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 if this difference in behavior is final.
  • Not sure on the best way to track whether a buffer has tree-sitter parsing.
    • Maybe track the buffers in compare.scopes instead of vim.b?
    • Would it be better to not track buffers and just pcall the affected locals.get_* methods?
  • 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 definitions once per update()
  • Clears previous results on each update, leading to more expected sorting (previously, nothing ever got removed or modified once it was put into the scopes_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

@pynappo pynappo force-pushed the patch-nvim-ts-main branch 3 times, most recently from 43b2d6d to a6be39a Compare August 9, 2024 23:51
@pynappo pynappo changed the title fix: Disable compare.scopes when no tree-sitter parser is present feat: Refactor compare.scopes Aug 10, 2024
@pynappo pynappo marked this pull request as ready for review August 10, 2024 00:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant