]> git.lizzy.rs Git - micro.git/blob - runtime/syntax/PowerShell.yaml
Create PowerShell.yaml
[micro.git] / runtime / syntax / PowerShell.yaml
1 # PowerShell syntax highlighting file for micro - https://micro-editor.github.io/
2 # PowerShell syntax taken from: https://github.com/PowerShell/EditorSyntax
3
4 filetype: powershell
5
6 detect:
7     filename: "\\.ps(1|m1|d1)$"
8     #header: ""
9
10 rules:
11     # - comment.block:           # Block Comment
12     # - comment.doc:             # Doc Comment
13     # - comment.line:            # Line Comment
14     # - comment.shebang:         # Shebang Line
15
16     # - constant:                # Constant
17     # - constant.bool:           # Constant (true, false)
18     # - constant.interpolation:
19     # - constant.number:         # Constant (null)
20     # - constant.specialChar:
21     # - constant.string:         # String
22     # - constant.string.char:
23     # - constant.string.url:     # Uri
24     # - constant.unicode:
25
26     # - identifier:              # Also used for functions
27     # - identifier.class:        # Also used for functions
28     # - identifier.macro:
29     # - identifier.var:
30
31     # - preproc:                 # Preprocessor
32     # - preproc.DebugIdentifier: # Preprocessor
33     # - preproc.shebang:         # The #! at the beginning of a file that tells the os what script interpreter to use
34
35     # - special:                 # Special (global|local|private|script|using|workflow)
36
37     # - statement:               # Statements Keywords
38     # - statement.built_in:
39     # - statement.declaration:   # Declaration Keywords
40     # - statement.meta:          # Meta
41     # - statement.reserved:      # Reserved Keywords
42
43     # - symbol
44     # - symbol.brackets:         # {}()[] and sometimes <>
45     # - symbol.operator:         # Operators
46     # - symbol.tag:              # For html tags, among other things
47
48     # - type
49     # - type.collections:        # Collections (array, hashtable)
50     # - type.ctypes:             # CTypes (CBool, CChar, etc.)
51     # - type.keyword:            # If you want a special highlight for keywords like 'private'
52     # - type.storage:            # Storage Types (int, uint, string, etc.)
53
54     # Class
55     - identifier.class: "class +[A-Za-z0-9]+ *((:) +[A-Za-z0-9.]+)?"
56     - identifier.class: "(function)(?:([[:space:]][A-Za-z0-9]+[[:space:]]*))"
57
58     # Verbs taken from PwSh 6.0.2
59     - identifier: "(Add|Approve|Assert|Backup|Block|Build|Checkpoint|Clear|Close|Compare|Complete|Compress|Confirm|Connect|Convert|ConvertFrom|ConvertTo|Copy)[-][A-Za-z0-9]+"
60     - identifier: "(Debug|Deny|Deploy|Disable|Disconnect|Dismount|Edit|Enable|Enter|Exit|Expand|Export|Find|Format|Get|Grant|Group|Hide)[-][A-Za-z0-9]+"
61     - identifier: "(Import|Initialize|Install|Invoke|Join|Limit|Lock|Measure|Merge|Mount|Move|New|Open|Optimize|Out|Ping|Pop|Protect|Publish|Push)[-][A-Za-z0-9]+"
62     - identifier: "(Read|Receive|Redo|Register|Remove|Rename|Repair|Request|Reset|Resize|Resolve|Restart|Restore|Resume|Revoke)[-][A-Za-z0-9]+"
63     - identifier: "(Save|Search|Select|Send|Set|Show|Skip|Split|Start|Step|Stop|Submit|Suspend|Switch|Sync|Test|Trace)[-][A-Za-z0-9]+"
64     - identifier: "(Unblock|Undo|Uninstall|Unlock|Unprotect|Unpublish|Unregister|Update|Use|Wait|Watch|Write)[-][A-Za-z0-9]+"
65     - identifier.var: "\\$(?i)((Global|Local|Private|Script|Using|Workflow)[:])?[A-Za-z0-9]*"
66
67
68     # Expression and types
69     - type: "\\[\\b([A-Za-z]+|[A-Za-z]+[0-9]+)\\b\\]"
70
71     # Keywords
72     - statement: "\\b(alias|as|begin|break|catch|continue|data|default|define|do|dynamicparam)\\b"
73     - statement: "\\b(else|elseif|end|exit|finally|for|foreach|foreach-object|from|if|in|inlinescript)\\b"
74     - statement: "\\b(parallel|param|process|return|switch|throw|trap|try|until|using|var|where|where-object|while)\\b"
75
76     # Special Keywords
77     - special: "\\b(break|continue|exit)\\b"
78
79     - symbol.brackets: "(\\{|\\})"
80     - symbol.brackets: "(\\(|\\))"
81     - symbol.brackets: "(\\[|\\])"
82     - symbol.operator: "[\\-+/*=<>?:!~%&|]"
83     - symbol.operator: "[[:space:]][-](ne|eq|gt|ge|lt|le|like|notlike|match|notmatch|contains|notcontains|in|notin|replace|is|isnot)[[:space:]]"
84
85     # Constants
86     - constant.bool: "\\b\\$(true|false|null)\\b"
87     - constant.number: "\\b([0-9._]+|0x[A-Fa-f0-9_]+|0b[0-1_]+)[FL]?\\b"
88
89     # Expression Mode String
90     - constant.string:
91         start: "\""
92         end: "\""
93         #skip: "\\\\."
94         rules:
95             - constant.specialChar: "\\\\([btnfr]|'|\\\"|\\\\)"
96             - constant.specialChar: "\\\\u[A-Fa-f0-9]{4}"
97
98     # Argument Mode String
99     - constant.string:
100         start: "'"
101         end: "'"
102         #skip: "\\\\."
103         rules:
104             - constant.specialChar: "\\\\([btnfr]|'|\\\"|\\\\)"
105             - constant.specialChar: "\\\\u[A-Fa-f0-9]{4}"
106
107     # Line Comment
108     - comment:
109         start: "#"
110         end: "$"
111         rules:
112             - todo: "(TODO|XXX|FIXME|BUG):?"
113
114     # Block Comment
115     - comment:
116         start: "<#"
117         end: "#>"
118         rules:
119             - todo: "(TODO|XXX|FIXME|BUG):?"
120
121     # Embedded C#
122     - default:
123         start: "@\""
124         end: "\"@"
125         rules:
126             - include: "csharp"
127
128     # Todo
129     - todo: "(TODO|XXX|FIXME|BUG):?"