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: Improve existing syntax highlighting #3

Merged
merged 7 commits into from
Sep 25, 2023

Conversation

WilsonZiweiWang
Copy link
Collaborator

Improve existing syntax highlighting

@WilsonZiweiWang WilsonZiweiWang added the enhancement New feature or request label Sep 20, 2023
@WilsonZiweiWang WilsonZiweiWang self-assigned this Sep 20, 2023
@WilsonZiweiWang WilsonZiweiWang force-pushed the Feature-10094-Improve-syntax-parser branch from 280e4af to d523087 Compare September 20, 2023 03:27
1. Differentiate function names and variable names
2. Add highlights for more keywords
3. Modularize some of the rules such as params
4. Re-order the patterns so specific rules will take precedence
@WilsonZiweiWang WilsonZiweiWang force-pushed the Feature-10094-Improve-syntax-parser branch from d523087 to 40fdc9f Compare September 20, 2023 20:13
@WilsonZiweiWang WilsonZiweiWang changed the base branch from master to staging September 21, 2023 14:27
Copy link

@gwerderm gwerderm left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I just stumbled across this pull request and found some things i would do slightly different. Also (I didn't comment this in the code) i was asking myself, what might has been the reason for you to remove the includes of "source.python" and "source.shell". I think using them could make it easier to write the code, while being sure that the code inside functions gets highlighted properly. But maybe I am wrong with that?

client/syntaxes/bitbake.tmLanguage.json Outdated Show resolved Hide resolved
client/syntaxes/bitbake.tmLanguage.json Outdated Show resolved Hide resolved
client/syntaxes/bitbake.tmLanguage.json Outdated Show resolved Hide resolved
client/syntaxes/bitbake.tmLanguage.json Show resolved Hide resolved
client/syntaxes/bitbake.tmLanguage.json Outdated Show resolved Hide resolved
client/syntaxes/bitbake.tmLanguage.json Outdated Show resolved Hide resolved
client/syntaxes/bitbake.tmLanguage.json Show resolved Hide resolved
client/syntaxes/bitbake.tmLanguage.json Outdated Show resolved Hide resolved
client/syntaxes/bitbake.tmLanguage.json Outdated Show resolved Hide resolved
client/syntaxes/bitbake.tmLanguage.json Outdated Show resolved Hide resolved
1. Add more keywords
2. Handle highlights within parens and braces
3. Handle nested patterns such as content within a pair of curly braces
1. Highlight numeric values
2. Highlight parenthesis
3. Highlight @ sign with ${}
4. Highlight boolean values
@WilsonZiweiWang
Copy link
Collaborator Author

I just stumbled across this pull request and found some things i would do slightly different. Also (I didn't comment this in the code) i was asking myself, what might has been the reason for you to remove the includes of "source.python" and "source.shell". I think using them could make it easier to write the code, while being sure that the code inside functions gets highlighted properly. But maybe I am wrong with that?

Thanks for the feedback, I pushed some new changes before I saw your comments. The new one should have fixed most of the issues you mentioned.

As for source.python and source.shell, they caused me some trouble at the beginning because some of the rules have conflicts. So I removed them. But you are right that they will save me some effort. To take advantage of them, I figure it would be better to include them in scopes that only Python-like or Shell-like code is present instead of in the global.

Copy link
Member

@idillon-sfl idillon-sfl left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks quite good. Just a bunch of corner cases I found:

# python should be colored as a variable
python = "test"

# inherit should be colored as a function name
python inherit () {}

# 'then' should be same color as 'if'
if [ somecondition ] ; then

# no idea what should happen, but this is weird
TEST = python inherit () {}

# This one too is weird
inherit from export inherit from test inherit test from inherit

That being said, don't hesitate to just merge and look at it later.

I would also suggest to use a json prettifier to set the indentation to 2 spaces so we can track the changes better.

1. Apply python-style highlighting on text within []
2. Improve highlighting on boolean values
@WilsonZiweiWang WilsonZiweiWang merged commit 1892112 into staging Sep 25, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants