Skip to content

fix(builtin.treesitter) Force eval treesitter #3449

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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

juliancoffee
Copy link

Description

I'm not sure if that's the best way to go about it, but that's the solution I came up with.
Please include a summary of the change and which issue is fixed. Please also
include relevant motivation and context

Fixes two problems.

  • treesitter locals aren't populated until it's executed for highlighting, indents, etc, so if you disable highlighting for a particular language (or all of them), it will return no symbols. I worked around this by forcing parser:parse(). If performance is unacceptable, we could make it an option, but for me, it worked well.
  • Some files for some languages simply don't return any definitions at all, and Treesitter silently ignores them.
    This PR displays them as errors. feat(builtin.treesitter) send user message if no symbols found. #3416 does something very similar, but because I needed both fixes for my fork, I include it as well 😅

Type of change

Please delete options that are not relevant.

  • Bug fix (non-breaking change which fixes an issue)

How Has This Been Tested?

Please describe the tests that you ran to verify your changes. Provide instructions so we can reproduce. Please also list relevant details about your configuration

  • Test A
    I've tested it Rust file while disabling treesitter highlighting.
    Returns nothing before this PR, after this PR returns symbols as expected.
  • Test B
    Tested on my own config files, which don't have any symbols that the Lua parser recognised as locals.
return {
  'example',
}

Configuration:

  • Neovim version (nvim --version):
NVIM v0.11.0
Build type: Release
LuaJIT 2.1.1744318430
Run "nvim -V1 -v" for more info
  • Operating system and version:
Darwin Kernel Version 24.3.0: Thu Jan  2 20:23:36 PST 2025

Checklist:

  • My code follows the style guidelines of this project (stylua)
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation (lua annotations)

+ Actually display the errors
@juliancoffee
Copy link
Author

nvim-treesitter/nvim-treesitter#7827

Ok, so I was told in treesitter repo that this is basically what we should do, and that parsing for already parsed file would be a no-op.

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