-
Notifications
You must be signed in to change notification settings - Fork 46
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
Decide on scope names for all language constructs #8
Comments
This is a great start! Curious to see what feedback @aeschli might have. |
Yeah, I have started by just filling out the scope names as I have used them. Hopefully we get some feedback from others in the community so we can decide/make changes as we agree on them :) |
What are good sources for existing scope names? |
Language files for other languages I guess. I tried looking at the built-in for c# that came with Sublime Text. That one was horrible :( |
https://manual.macromates.com/en/language_grammars is the textmate spec. I also found http://www.apeth.com/nonblog/stories/textmatebundle.html useful. |
@aeschli I looked at the TextMate documentation, but it's not always easy to figure out what scope name to use, so it would be good to have a discussion to come to some kind of agreement, regarding PowerShell as a language. |
NOTE: This is attempting to colorize powershell syntax correctly and is not attempting to assign the technically correct scopes at all. These are the main issues that I ran into that I think should be changed: Variable - $ keyword.other '$' in $variable Having all of these as different scopes causes a huge amount of variation between themes that I tested vs powershell ISE. From what I can tell the color of variable.other.readwrite is the color that powershell ISE uses for all of the above variables in every theme that I found. That would mean changing all of the above to variable.other.whatever would be a great way to keep coloring consistent across all themes and editors. Examples: Keyword.other.* and keyword.operator.* : Most of the time these are using the default text color in Powershell ISE(read as every theme I tested). If the editor theme includes keyword.operator or keyword.other specifically it sets the color to the default text color. The issue is when many themes do not have these specified, and you end up with tons of operators being the colors of the keywords, which in ISE this color is mainly just used for keyword.control. This was rather frustrating as I could not find a consistent way to represent these as just the simple text color across multiple themes, is there anything they could be set to that would consistently set them to the default text color? If not this might be something that requires updating themes instead of updating scopes. Examples: any operator is affected "+ - = == =+ * / | - -match -replace -le ++ etc." Things I know are wrong but don't know how to fix yet: [string] $muffins[0] "[ and ]" I am not exactly sure what brackets are being classified as but they are not working well with themes. They are the same as the operators above where they are always the default text color in ISE, but often cause a ton of color contrast for no reason with the other editors. |
Making all of those changes(still don't know how to edit the brackets) makes the following difference. As you can see it looks much much better. I have tried it in several different themes and compared with similar results. |
Very good demonstration Allieway! My number one reason that I'm not using the VSCode for Powershell projects is the confusing and distracting highlighting. It really should be consistent with ISE. |
We need to reopen this discussion. In my recent changes I followed https://www.sublimetext.com/docs/3/scope_naming.html and compared to some other language syntaxes. Should we continue here or start fresh? |
I'd like to have a discussion where we decide on the "correct" scope names for all PowerShell language constructs. This will mean much less work when doing updates to the tmLanguage file in the future, as the scopes (as well as the color(!) of each) are checked by a Travis CI build job on the vscode repo.
General
.powershell
As we decide, we can fill out this table:
# comments
<# comments #>
.SYNOPSIS
.PARAMETER ParameterName
#Requires -Version 3.0
#Requires -Version 3.0
"string"
'string'
t' in
"onettwo"
{ ... }
$( ... )
@{ ... }
@(1,2,3)
&(1,2,3)
(Invoke-Something).property
& 'property' in$var.property
+.5
5
0x20
[string]
[int]::MinValue
[Parameter(Position = 1)]
[Parameter(Position = 1)]
function script:Invoke-Something { ... }
function script:Invoke-Something { ... }
function script:Invoke-Something { ... }
Invoke-Something -p1 'v1'
Invoke-Something -p1 'v1'
configuration
break
enum myEnum { ... }
enum myEnum { ... }
class myClass : inheritedClass { ... }
class myClass : inheritedClass { ... }
class myClass : inheritedClass { ... }
hidden
&static
: base( ... )
2>&1
-gt
-band
-and
-f
+=
-not
&!
/
&*
+
-
+
&-
..
&
--%
switch -regex ($var) { ... }
switch -regex ($var) { ... }
default
$variable
${variable}
$_
&$error
$script:variable
$script:variable
I have started by filling out the scope names as I have used them in my refactored language file.
About scopes and highlighting
If, in the theme, there are colorization rules only for the scope constant.operator, both constant.operator and constant.operator.range will be colorized the same.
If there isn't any colorization rules for a scope, it will be colorized with the "root" color of the current scope. Meaning if the word 'test' only belong to the source scope (or have a scope name that is not defined in the current theme), it will be colorized with the default background color. If the word 'test' is found inside another scope, for instance a string, it will be colorized with the color for the string scope.
Colorization rules may differ between editors. For instance the background parameter. This is supported on Sublime Text, but not in VSCode.
A matched set of characters can be (and more often than not are) assigned multiple scopes. So for example the word variable in
function MyFunction {"this is $("a $variable")"}
have the following scopes: source, string.quoted.double, meta.subexpression, string.quoted.double and lastly variable.other.readwrite. Only the last one is used for colorization.About the default themes in VSCode
There are five themes that are defined as default themes in Visual Studio Code:
The themes supports nesting, and:
The following scopes are defined in the plus-themes:
The following scopes are defined in the "old" default themes:
Scope names on the same line, means they are defined in the same colorization rule.
The text was updated successfully, but these errors were encountered: