Skip to content

Conversation

LemmusLemmus
Copy link
Contributor

@LemmusLemmus LemmusLemmus commented Mar 24, 2025

This pull request adds syntax highlighting for raw strings (#196) and autoClosingPairs.

Implementation notes

  • Since autoClosingPairs does not seem to support regex open/close, I have had to repeat a couple of possible raw string pairs. One could add more...
  • The current highlight color chosen (for r, # and the string itself) is of course opinionated. I just choose that which I found easiest to implement.
  • I have not added the condition "notIn": ["comment"], because while typing a raw string, one enters a comment r#, and the notIn would therefore always fail. This could be changed however, depending on question 3. below.

Questions

  1. Some raw string examples should probably be included in example.nu, however that file is generated and so I do not know how the example strings should be added.
  2. Unrelated, but what is the autoClosingPair /** */ used for in the Nushell language?
  3. Also unrelated, but I noticed that the syntax highlighting of e.g.
    echo hello#there
    is also wrong. #there is not considered as a comment by Nushell, but rather as a part of (in this case) the bare string. For a comment to actually be a comment, I think that there must be either a new line or white-space before it, i.e. by replacing the current regex "match": "(#.*)$" with "match": "(?<=^|\\s)(#.*)$".

@fdncred
Copy link
Contributor

fdncred commented Mar 24, 2025

Thanks for the PR.

Unrelated, but what is the autoClosingPair /** */ used for in the Nushell language?

no clue. probably shouldn't be there.

is also wrong. #there is not considered as a comment by Nushell

sounds like a bug

@fdncred
Copy link
Contributor

fdncred commented Mar 24, 2025

seems good enough to me. thanks!

@fdncred fdncred merged commit 3b7b5f5 into nushell:main Mar 24, 2025
1 check passed
@LemmusLemmus
Copy link
Contributor Author

Would you appreciate another PR for removing the /** and changing the comment regex?

@fdncred
Copy link
Contributor

fdncred commented Mar 24, 2025

sure

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