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

tree-sitter and lsp for python and R #88

Merged
merged 2 commits into from
Feb 18, 2025
Merged

Conversation

davcam
Copy link
Contributor

@davcam davcam commented Feb 12, 2025

This is to add some configuration to get tree-sitter and LSP working in a minimal way for python and R. #87

Python in ad
ad-python

R in ad
ad-R

@sminez
Copy link
Owner

sminez commented Feb 12, 2025

The import builtinsbuiltins as _builtins line in the python screenshot looks odd...I think that's the same piece of text matching multiple queries? If so then that's a bug in how I'm processing the query results but there's no universally correct way to handle that: you need to make a call on whether you keep the first or last match (which I thought I was doing 😕)

@davcam can you double check that for me please? Assuming that its not literally the string builtinsbuiltins I'll need to find a fix for this and that may end up changing how your queries are being applied, so I'll leave this PR open for now as something I can test against 🙂

@davcam
Copy link
Contributor Author

davcam commented Feb 12, 2025

@sminez you are right there is an issue

It should be
import builtins as _builtins

it seems to occur for
import modulename as othername

"modulename" is repeated as you identified

whereas not for
import modulename
or
from modulename ....

You'll see from the commit that I haven't changed the colours in config.toml. My guess is that it is confusing "module" which is set to "#2D4F67" (the second builtin colour I think in the screenshot) with something else?

@sminez
Copy link
Owner

sminez commented Feb 12, 2025

Thanks! I'll try to get to the bottom of what's going on when I have some time to investigate 🙂

@davcam
Copy link
Contributor Author

davcam commented Feb 12, 2025

A bit more digging.
in
import modulename as othername
it is identifying "modulename" as both a
"variable" and a "module"

@sminez
Copy link
Owner

sminez commented Feb 12, 2025

yeah that's the sort of thing I was thinking. In that case what should be happening is that the second pattern to match gets dropped. But admittedly, the code for this is pretty naive and is essentially still just the first pass I had when I was trying to get to grips with the tree-sitter API in the first place.

I might have some time in a bit to set this up as a test case using just those two queries and the single line of code and sort things out from there 🤞

@sminez
Copy link
Owner

sminez commented Feb 13, 2025

@davcam would you be able to try out your queries on the PR branch I have open for #89? Part of the fix is to match neovim's precedence rules for overlapping queries which is probably going to mess how you've ordered things in your highlights.scm file I'm afraid. I'll get things fixed up for the existing files once I've confirmed that there aren't any other issues that need to be fixed as part of this.

@sminez
Copy link
Owner

sminez commented Feb 14, 2025

@davcam I've merged #89 after getting some confirmation that it is fixing the issue reported in #76. If you rebase your PR branch now you should have working highlights 🙂

@davcam
Copy link
Contributor Author

davcam commented Feb 18, 2025

Thanks @sminez once I removed offending lua-match's in R and python highlights files I have working syntax highlighting again and the duplication issue is fixed. If I've done the rebase correctly hopefully this PR can be merged.

@sminez
Copy link
Owner

sminez commented Feb 18, 2025

fantastic! Thanks for contributing these @davcam 🙂

@sminez sminez merged commit dd1d61b into sminez:develop Feb 18, 2025
6 checks passed
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.

2 participants