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

Python highlight improvements: type, parameter etc #1

Merged
merged 1 commit into from
May 13, 2022

Conversation

paul-scott
Copy link
Collaborator

  • str, list, etc. handled as @function.builtin and @type.builtin
  • None and non-conforming type indentifiers as @type in type hints
  • class identifiers treated as @type
  • @constructor used for constructor definitions and calls rather than
    as a catch-all for type-like things
  • Parameters highlighted
  • self and cls as @variable.builtin
  • improved decorator highlighting as part of @function

Re-ordering of some statements to give more accurate priority.

* str, list, etc. handled as @function.builtin and @type.builtin
* None and non-conforming type indentifiers as @type in type hints
* class identifiers treated as @type
* @constructor used for constructor definitions and calls rather than
  as a catch-all for type-like things
* Parameters highlighted
* self and cls as @variable.builtin
* improved decorator highlighting as part of @function

Re-ordering of some statements to give more accurate priority.
@paul-scott
Copy link
Collaborator Author

Hey I've decided to chuck everything in at once. Have a try of this. If you are happy then you can merge it, and then take a look at the upstream PR to see if it updates with these new changes. You can reopen your upstream PR if you are happy.

@Zeddicus414 Zeddicus414 merged commit fc84edd into Zeddicus414:master May 13, 2022
@Zeddicus414
Copy link
Owner

Zeddicus414 commented May 13, 2022

It looks great! Here is the only problem I see that I haven't been able to track down why it really wants that nested "None" to be blue:
image

At first I thought it was a nesting problem... but that doesn't seem to be it. Nesting 7 times instead of 4 wasn't even enough.

And here is another tiny bug:
image

@Zeddicus414
Copy link
Owner

Hi @paul-scott , thank you so much for being so responsive, I keep looking into issues and not really finding solutions and you are crazy on top of it.

Here is the test file I've been using:
syntax_test.txt

This doesn't show up like mine did?

The Tree-Sitter Playground seems to agree with my copy of helix too:
image

Another fun edge case that might not be fixable:

image

@paul-scott
Copy link
Collaborator Author

You said that you increased the nesting and it didn't help. Did you do that in the above? If I change it to the following it works.

; Handle [] . and | nesting 6 levels deep
(type
  (_ [(identifier) (none)]? @type
    (_ [(identifier) (none)]? @type
      (_ [(identifier) (none)]? @type
        (_ [(identifier) (none)]? @type
          (_ [(identifier) (none)]? @type
            (_ [(identifier) (none)]? @type)))))))

As I said I thought it would be prudent to keep it at fewer levels for now.

Your test file identified another issue with the decorator colouring.

@Zeddicus414
Copy link
Owner

You are right. I think I just got my parentheses in the wrong place during the nesting and had siblings rather than nested structures.

@paul-scott
Copy link
Collaborator Author

paul-scott commented Oct 11, 2022 via email

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