jrsconfitto / language-powershell Goto Github PK
View Code? Open in Web Editor NEWPowerShell language support for the Atom editor
Home Page: https://atom.io/packages/language-powershell
License: Other
PowerShell language support for the Atom editor
Home Page: https://atom.io/packages/language-powershell
License: Other
The problem I want to bring attention to is on variable syntax highlight/coloration/formatting
And I have seen this both for sublime text, atom, and VS code
basically the formatting is INCORRECT when under ""
I can understand if it was ' '
but in "" the variables are still quite functional.... and often there is text which is DIFFERENT from the variable inside like
"$variable-hello there how are you"
And we need to be able to differentiate that
The list of approved verb has been updated in PowerShell v6 to include the following verbs:
Verb (alias) | Action | Comments |
---|---|---|
Build (bd) | Creates an artifact (usually a binary or document) out of some set of input files (usually source code or declarative documents) | This verb was added in PowerShell v6 |
Deploy(dp) | Sends an application, website, or solution to a remote target[s] in such a way that a consumer of that solution can access it after deployment is complete | This verb was added in PowerShell v6 |
It seems that the grammar has already been updated on PowerShell/EditorSyntax (see issue #147).
Could you update the package with the new grammar?
AppVeyor CI build is hanging on cinst Atom
while it's waiting for user input and then the build times out.
Possibly add a -Force
flag to cinst Atom
in appveyor.yml
?
I can test once I have a Windows system in front of me again :)
Multi-line strings.
Begin with @"
End with "@
All characters after an escape character get colored the same. See this example https://i.imgur.com/7sKxm12.png
and leave the pane empty (without any tabs inside) but still there
As per this Atom post describing language-specific settings. i want to support these in this language, but need to research what (if anything) i need to do to do that.
Resources:
If I escape a double-quote symbol (") inside a quote, it doesn't propery work.
$command = ".\myfile.ps1 -param1 `"$myvar`" -param2 whatever"
-> the end of the string is considered outside the string.
With the new son-of-obsidian based theming (that look rough on light colored themes), it's time to figure out atom theming and adjust this plugin to play nice with atom themes.
Here-strings -- strings that begin with @"
and end with "@
on another line -- are not correctly identified. As a result, any code below a here-string is colored as if it was a string.
In the following example, everything after "@
is being highlighted as a string in Atom with the language-powershell package.
function Foo
{
$SomeLongString = @"
This is a here-string in PowerShell.
"@
}
function Bar
{
Write-Host "Bar"
}
Any chance this could get fixed? I'm loving the package, so thanks for making it!
Update: Better problem statement right below: #24 (comment)
$SomeComputer = 'localhost'
$RemoteServicePS = @{
'VMware' = @{
'Service' = $(get-service -verbose:$false -computername $SomeComputer -displayName 'VMware Tools');
'EndpointContracts' = @('ISimService','IServiceBroker');
'Identity' = '';
};
}
$ServicesToSkip = @()
$RemoteServiceCIM = @{}; $HasServicePrincipalNames = @{}
$RemoteServicePS.GetEnumerator() | % {
$thisServiceKey = $_.Key
if ($_.Value.Service -ne $null){
$thisCIMService = $(get-ciminstance win32_service -verbose:$false -computername $_.Value.Service.MachineName -filter "name='$($_.Value.Service.ServiceName)'")
$thisCIMServiceUser = $thisCIMService.StartName
write-host $thisCIMServiceUser
# etc.
}
}
After updating language-powershell to the most recent release the following from the code above breaks code highlighting for me:
$thisCIMService = $(get-ciminstance win32_service -verbose:$false -computername $_.Value.Service.MachineName -filter "name='$($_.Value.Service.ServiceName)'")
The same also appears to be the case for the following little snippet (code hightlighting continues as before if commented out):
$thisBitVersionMatches = $FilesPresent | where {$_.FullName -match "^(?=.*$thisVersion)((?=.*$thisBitness)|(?=.*$thisSupportBit))(?=.*redist).*$"}
I also see the issue in places such as this:
foreach ($Tool in $Tools){
$ToolFromWhere.Keys | % {
if (($_ -match $Tool) -and -not ($ToolsToDownload -contains $ToolFromWhere."$($_)")){
write-verbose ('Fetching {0} from {1}' -f $_, $ToolFromWhere."$($_)")
$ToolsToDownload += $ToolFromWhere."$($_)"
[URI]$thisURI = $ToolFromWhere."$($_)"
$thisFileName = $thisURI.Segments[-1]
$thisTempFile = join-path -path $env:TEMP -childpath $thisFileName
start-bitstransfer -source $thisURI -destination $thisTempFile
Where if I comment out lines [3-6] highlighting continues.
Another example where the Where line breaks highlighting:
Get-ChildItem 'HKLM:\SOFTWARE\Microsoft\NET Framework Setup\NDP' -recurse |
Get-ItemProperty -name Version,Release -EA 0 |
Where { $_.PSChildName -match '^(?!S)\p{L}'} |
Select PSChildName, Version, Release, @{
name="Product"
expression={
switch($_.Release) {
My gut feeling says it's related to PR50 since it's all directly after a foreach/where, but I'm not really sure. Is there anything I can do to provide a clearer report/exclude other potential sources of the issue?
Whenever I wrap a block of code within a region, the plugin does not parse it as code that can be folded.
Can this ability be added to the script, or is this something I can force in Atom configuration?
It would be great to add the automatic variables to the grammar.
Docs: about_Automatic_Variables.
I try to run Powershell scripts, and I get the following error:
File C:\Users\Documents\WindowsPowerShell\Microsoft.PowerShell_profile.ps1 cannot be loaded because running scripts is disabled on this system.
In a Powershell shell, I have confirmed that the policy is "Unrestricted" for both the user and the administrator. I have also run the script file as the user and administrator in a Powershell console.
I have tried this as my regular user, and running Atom as administrator.
It is a Windows 10 system.
Thanks.
Hi !
There is a problem with the operators highlighting: when I run a custom method with a parameter which name starts with a global operator name, only the start of the parameter is highlighted. For instance, My-Method -equal "test"
will highlight the "eq" part of the "equal" parameter.
There is another problem as well, but I'm guessing it's harder to fix. For instance I'm using a -from
and a -to
parameters, the -from
is highlighted (because it's a keyword), but not the -to
.
Hi, on my Mac I tried the add-on, but once I save the file it won't work.
I save it as .ps1
One thing that might be of interest to you is the new Tree Sitter parsing system that recently got merged into Atom's master branch (coming to Atom Beta 1.25 next month). This will enable a much more faithful highlighting of PowerShell once a Tree Sitter grammar is written for it, plus some other potentially nice editing features that having an in-editor AST would allow. I think it'd be great for language-powershell to be the place where this new grammar lives!
/cc @Jaykul
when I am defining multiline strings the first @ makes all the following lines color look like it is in "quotes"
the second @ should cancel the first out
example:
$myString = @"
This is the first line
This the second line
This is the third line
"@
Originally, i thought that highlighting $ variables wasn't working. Turns out it is, except in the following situation:
Function Fail([string]$Message = "") {
The settings for soft or auto tab types seem to be ignored. When editing a file with the tab type set to "soft", pressing the tab key always inserts a tab character.
The auto tab type may or may not correctly detect whether the source file is using spaces or tabs, but has the same result as choosing "soft" in the settings: pressing the tab key (or using autoindent) inserts a tab character instead of spaces.
When I use "Where-Object" it does not highlight in turquoise like the other cmdlets. Instead "Where" highlights purple and "-Object" highlights gray. Not sure if this is purposeful but seems like it should highlight turquoise like all other cmdlets.
Try this search for more information.
For example:
Param(
[string]$Configuration = "Release",
[string]$Platform = "x86",
[switch]$Tests
)
According to the PowerShell comparison operators reference, prepending the operators with i
or c
will change how they match. i don't think the grammar allows this. From the reference:
By default, all comparison operators are case-insensitive. To make a comparison operator case-sensitive, precede the operator name with a "c". For example, the case-sensitive version of "-eq" is "-ceq". To make the case-insensitivity explicit, precede the operator with an "i". For example, the explicitly case-insensitive version of "-eq" is "ieq".
When calling the property of an object, the property itself is highlighted in the exact same colour. In version 4.0.1, both had a distinct colour.
$String.Length
I checked with all available default Atom themes and the behaviour is the same.
i wonder if this is what's planned for the future: https://code.visualstudio.com/docs/extensions/example-language-server#_implement-your-own-language-server
Consider multe-line string
"This is
a string"
I used lightshow to verify it on the latest version of the grammar:
http://goo.gl/cZkift
See morkro/atom-emoji-syntax#50.
I don't understand enough about this works to explain the problem properly, but it seems morkro has explained it well in the issue referenced.
I briefly checked the language-powershell package, and it doesn't really come with meaningful syntax descriptors. That means I can't add emoji to specific keywords, as they're too generic. :(
Would love to add support, but the way atom-emoji-syntax is build it requires meaningful keyword selectors.
Edit: I checked some more code examples, and found that Function does have a specific specifier. I could at least support for that.
It seems like replicating what has been done with the Function keyword would be adequate.
I would like to see selectors for classes, workflows, control structures, scopes, attributes, etc.
If you tell me how I will happily attempt make a pull request, but I would need quite a detailed guide, so it might be less work to just do it. Also, tell me if there is any research I can do to help the issue to be solved.
@morkro: If I have misrepresented the issue, please correct me.
Hi,
I'm new to atom, when try to install powershell package I'm getting Compiler tools not found error. I'm guessing I missed a config somewhere. Could you please give me hand with this or point me to a wiki somewhere.
Thanks
H.
I have Auto Indent and Auto Indent On Paste both checked in the package settings. When I try to paste pre-indented content, it is always pasted left aligned. It appears to be stripping out all indents on paste instead of auto indenting.
Currently, pressing `, n results in
`n`
I expect that pressing `, n results in
`n
It makes sense to insert a second backtick when writing markdown since it's used for code spans, but not at all useful in PowerShell since backticks denote escaped characters.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.