r/PowerShell • u/lan-shark • 27d ago
Script Sharing Syntax highlighting for PS7's null operators in VS Code
https://github.com/BryanCuneo/ps-null-operator-scopesI saw a comment on here earlier today about VS Code's syntax highlighting for PowerShell not being able to properly color PowerShell 7's null operators: ??, ??=, ?., and ?[]. I had never noticed this before because I've never even tried to do that, but it turns out that there is not built-in tokenization for these operators despite a 7 year old issue on the topic. I'd never written a VS Code extension before and this seemed like a fairly easy first task, so I wrote a small MIT-licensed extension that allows you to add syntax highlighting to these operators. Source code on GitHub here, install it from the VS Marketplace here.
Was pretty fun to build, though I don't know how practical it'll be for me since I use pretty minimal syntax highlighting personally. But I got to learn how to build and publish a VS Code extension and I'm considering tackling that GitHub issue and getting this functionality into the official highlighter. No promises though lol
I did use an LLM to help me find documentation, fix some errors in my JSON, and remind me how to write regex lookbehinds. I didn't use any agent system to write or publish the extension or documentation for me.
3
u/omers 27d ago
Props for seeing something that needed fixing and doing it. I used to maintain the PowerShell/EditorSyntax repo but walked away for reasons we won't get into. It's unfortunate that it hasn't been shown any love in many years it seems.
2
u/BlackV 27d ago
Nice!