Skip to content

Create Lexer for Nu #1110

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

Merged
merged 4 commits into from
Jul 22, 2025
Merged

Conversation

bizmythy
Copy link
Contributor

Closes #1003

This adds a lexer for nushell.

I began by converting the lexer provided by the pygments-nushell package using _tools/pygments2chroma_xml.py.

This got me most of the way there, but there were issues parsing interpolated strings. I then modified the generated nu.xml to handle these cases correctly.

I added lexers/testdata/nu.actual based on segments from the Nushell Book

Here is an example generated HTML document with highlighting (based on the test case added).

Let me know if the commits should be reformatted, I was unsure how they should be structured.

@alecthomas
Copy link
Owner

Thanks that's awesome!

@alecthomas alecthomas merged commit a53c924 into alecthomas:master Jul 22, 2025
2 checks passed
@bizmythy
Copy link
Contributor Author

bizmythy commented Jul 22, 2025

side note I forgot to include: the source for the examples is the nushell book is MIT licensed and the source for the pygment lexer is BSD-0 licensed, which are both compatible with this repo's license.

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.

Add support for NuShell
2 participants