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

Highlight (import, export module references) #1580

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

Conversation

zoodogood
Copy link
Contributor

@zoodogood zoodogood commented Nov 5, 2024

The import path now has the same highlighting as the string literal (string.unquoted.module-reference.civet). Previously it could be colored with anything

image

Before pull

  • Highlight export a, b from x too
  • Backward Import/Export from x import {a, b}
  • import default, {} from x
  • Replace \S to [^;\\s=>]+
    image

I have been unable to determine the correct method for intercepting the block completion

with
  type: "json"

so this part is not part of the import expression, which is semantically wrong. Any criticism is welcome, I'm inexperienced

@edemaine
Copy link
Collaborator

edemaine commented Nov 5, 2024

Could you rebase against our main branch? There seems to be a lot of other commits here.

@zoodogood
Copy link
Contributor Author

Oops. I'm redoing the pull request now. Or does it merge into pure history?

@zoodogood
Copy link
Contributor Author

Yeah, I noticed that, too. It's gonna take me a little while

@edemaine
Copy link
Collaborator

edemaine commented Nov 5, 2024

If you setup a remote of upstream to refer to our repo/fork (git remote add upstream [email protected]:DanielXMoore/Civet.git), then git rebase -i upstream/main, then git push -f (after checking everything is still OK), the PR will update.

@zoodogood
Copy link
Contributor Author

If you setup a remote of upstream to refer to our repo/fork (git remote add upstream [email protected]:DanielXMoore/Civet.git), then git rebase -i upstream/main, then git push -f (after checking everything is still OK), the PR will update.

Thank you, that helped.

lsp/syntaxes/civet.json Outdated Show resolved Hide resolved
}
},
{
"match": "\\b(?<![\\.\\$])(break|by|case|catch|continue|else|finally|for|in|of|if|return|switch|then|throw|try|unless|when|while|until|loop|do|export|import|default|from|as|yield|async|await|with|(?<=for)\\s+own)(?!\\s*:)\\b",
Copy link
Collaborator

Choose a reason for hiding this comment

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

Not related to this PR, but while I look at this, we have a bunch more for keywords, such as each and the reducers sum etc.

@zoodogood zoodogood changed the title Syntax highlighting(import) Highlight (import, export module references) Nov 8, 2024
@zoodogood
Copy link
Contributor Author

@edemaine I think it's ready. Can you check?

Thank you for taking the time to check the code and suggesting ways to improve it


{
"name": "string.unquoted.module-reference.civet",
"match": "(?<=(^\\s*(import|export)|^)\\s*(type\\s+)?((\\w+\\s*,\\s*)?\\{(.|\\n)*\\}|\\w+|(\\*\\s+as\\s+\\w+))\\s+(from)\\s+)([^\\(\\{\\[\"';\\s=>][^\"';\\s=>]+|\".+?\"|'.+?')(?=[^()]|$)"
Copy link
Collaborator

@edemaine edemaine Nov 8, 2024

Choose a reason for hiding this comment

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

\\{(.|\\n)*\\} seems rather inclusive. Perhaps (.|\\n) should be replaced by [^{}]? Or at least * should be *?, like the quoted string regexes.

I also realize that, if you're just trying to match unquoted module references here, you don't actually need |\".+?\"|'.+?'. (If you keep them, shouldn't + be *?)

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