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

Add syntax highlighting support for Powershell scripts #3123

Closed
lucypero opened this issue Jul 20, 2022 · 13 comments · Fixed by #9827
Closed

Add syntax highlighting support for Powershell scripts #3123

lucypero opened this issue Jul 20, 2022 · 13 comments · Fixed by #9827
Labels
A-tree-sitter Area: Tree-sitter C-enhancement Category: Improvements E-help-wanted Call for participation: Extra attention is needed

Comments

@lucypero
Copy link
Contributor

lucypero commented Jul 20, 2022

Describe your feature request

Edit: The following tree-sitter grammar doesn't work:
Treesitter: https://github.com/powershell/tree-sitter-powershell

@lucypero lucypero added the C-enhancement Category: Improvements label Jul 20, 2022
@sudormrfbin sudormrfbin added E-good-first-issue Call for participation: Issues suitable for new contributors E-help-wanted Call for participation: Extra attention is needed E-easy Call for participation: Experience needed to fix: Easy / not much A-tree-sitter Area: Tree-sitter labels Jul 21, 2022
@AceofSpades5757
Copy link
Contributor

I wasn't able to get it to work either. I'm not even sure why and I'm not sure if we'll ever know why.

@lucypero
Copy link
Contributor Author

lucypero commented Jul 28, 2022

I wasn't able to get it to work either. I'm not even sure why and I'm not sure if we'll ever know why.

I am trying with a fork I made of the tree-sitter grammar. I think I'll make it work soon.

@AceofSpades5757
Copy link
Contributor

I created an issue with them. Hopefully, they'll get it sorted as well.

PowerShell/tree-sitter-PowerShell#8

@the-mikedavis
Copy link
Member

It looks like that grammar is a work-in-progress based on the TODOs in the README, and it has a generation failure on the latest tree-sitter-cli as you noted. That project most likely needs some contributions to be more complete, or a new attempt (that one looks a bit dated).

@AceofSpades5757
Copy link
Contributor

It almost looks abandoned, although I'd be a bit surprised seeing as it should be the "official" one.

@the-mikedavis the-mikedavis removed E-easy Call for participation: Experience needed to fix: Easy / not much E-good-first-issue Call for participation: Issues suitable for new contributors labels Jul 28, 2022
@lucypero
Copy link
Contributor Author

So, I started adding highlight queries on my fork, then I realized that the parser parsed my powershell file all wrong. Someone probably should start to do the grammar from scratch. This one is just broken. I might do it one day.

@lucypero
Copy link
Contributor Author

lucypero commented Aug 2, 2022

This Page describes the PowerShell grammar. This will be very helpful when making the tree-sitter grammar.

@Joe-Zer0
Copy link
Contributor

This looks like an active LSP for PowerShell - https://github.com/PowerShell/vscode-powershell. But I'm unsure how to install it use it with Helix.

@daephx
Copy link

daephx commented Aug 23, 2023

This looks like an active LSP for PowerShell - https://github.com/PowerShell/vscode-powershell. But I'm unsure how to install it use it with Helix.

I don't recall if it has semantic highlighting but I've used it in neovim. The repo states in the first few paragraphs of the README that the vscode extension is basically a wrapper for PowerShellEditorServices if that helps you search for helix specific references.

@Joe-Zer0
Copy link
Contributor

Thanks. I've spent a few hours searching for "helix powershell". Unfortunately, this thread is about the only thing that comes up. Up till now all the LSP's I needed have been available through npm, cargo, pip. So getting this thing installed will be the first step.

@lrottach
Copy link

Hi @Joe-Zer0
I got the PowerShell Editor Services up and running in my Helix configuration on a MacBook Pro.
You find some more details in this discussion here: #3956

Unfortunately, this only implements auto-completion for PowerShell scripts, not syntax highlighting.
For syntax highlighting, someone would still have to develop the grammar. Unfortunately, I know too little about this.

@Joe-Zer0
Copy link
Contributor

Joe-Zer0 commented Aug 23, 2023

@lrottach - Thank you, that's exactly what I needed!
I also found this - https://github.com/PProvost/vim-ps1 - which looks like it could be helpful in configuring syntax highlighting. But I'm in too far over my head to do anything with it.

EDIT:
Here is another project that may help with syntax highlighting - https://github.com/PowerShell/EditorSyntax.

@LucasWagler
Copy link
Contributor

LucasWagler commented Jan 26, 2024

The tree-sitter site now mentions this grammar from Airbus CERT.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-tree-sitter Area: Tree-sitter C-enhancement Category: Improvements E-help-wanted Call for participation: Extra attention is needed
Projects
None yet
Development

Successfully merging a pull request may close this issue.

8 participants