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

[ShellScript] Add ZSH #4024

Merged
merged 114 commits into from
Oct 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
114 commits
Select commit Hold shift + click to select a range
990153d
[ShellScript] Fix job built-ins
deathaxe May 13, 2024
dc641e5
[ShellScript] Fix brace expansions
deathaxe May 13, 2024
e4400fe
[ShellScript] Fix tilde expansions
deathaxe Jun 6, 2024
2425757
[ShellScript] Refactor parameter expansions
deathaxe May 11, 2024
b9be302
[ShellScript] Refactor redirections
deathaxe Jun 12, 2024
27932bd
[ShellScript] Refactor subscriptions
deathaxe Jun 16, 2024
ac63597
[ShellScript] Fix function identifiers
deathaxe Jun 15, 2024
94ca368
[ShellScript] Exclude linefeed from continuation punctuation
deathaxe Jun 23, 2024
cb84818
[ShellScript] Replace various anonymous contexts in Bash
deathaxe May 8, 2024
0b44a93
[ShellScript] Scope function body meta.block
deathaxe May 8, 2024
fabf292
[ShellScript] Refactor case statement contexts
deathaxe May 11, 2024
055a76b
[ShellScript] Add paths patterns
deathaxe Jul 14, 2024
559aa33
[ShellScript] Refactor command arguments' word boundaries
deathaxe Jul 6, 2024
7d69e14
[ShellScript] Reorganize literals
deathaxe Jul 21, 2024
5e24433
[ShellScript] Special echo treatment
deathaxe May 10, 2024
5cfa023
[ShellScript] Tweak builtin test command arguments
deathaxe Jul 14, 2024
7b2fc8f
[ShellScript] Remove obsolete brace expansion contexts
deathaxe Jul 14, 2024
904edb6
[ShellScript] Scope built-in variables
deathaxe Jul 20, 2024
02f0bb7
[ShellScript] Reorganize expressions
deathaxe Jul 21, 2024
c032c5f
[ShellScript] Reorganize literals
deathaxe Jul 21, 2024
ef210ad
[ShellScript] Add arithmetic highlighting in assignment values
deathaxe Jul 20, 2024
cbce584
[ShellScript] Reorganize variables
deathaxe Jul 22, 2024
7e54127
[ShellScript] Tweak number word breaks
deathaxe Jul 24, 2024
3617431
[ShellScript] Avoid duplicate patterns in statement
deathaxe Jul 21, 2024
14db338
[ShellScript] Fix comments after heredoc tags
deathaxe Jul 21, 2024
814edf2
[ShellScript] Reorganize prototypes at the bottom
deathaxe Jul 24, 2024
c24ac9f
[ShellScript] Remove obsolete compound args contexts
deathaxe Jul 26, 2024
d989c70
[ShellScript] Simplify coproc
deathaxe Jul 26, 2024
87e4a5b
[ShellScript] Refactor tilde interpolation scopes
deathaxe Jul 27, 2024
d3f71ed
[ShellScript] Align illegal token scopes
deathaxe Jul 27, 2024
4decce0
[ShellScript] Simplify alias meta scope
deathaxe Jul 29, 2024
8d5d465
[ShellScript] Simplify declaration meta scope
deathaxe Jul 29, 2024
d2d7e86
[ShellScript] Refactor anonymous function definitions
deathaxe Jul 30, 2024
3c09b5e
[ShellScript] Refactor command arguments
deathaxe Jul 30, 2024
fa33e93
[ShellScript] Add missing option word boundaries
deathaxe Jul 30, 2024
84eebb1
[ShellScript] Fix for arguments
deathaxe Jul 30, 2024
fe77936
[ShellScript] Simplify arithmetic command
deathaxe Jul 31, 2024
a732586
[ShellScript] Refactor arithmetic expressions
deathaxe Jul 30, 2024
416660c
[ShellScript] Refactor conditional compound commands
deathaxe Aug 1, 2024
2a4aac1
[ShellScript] Refactor compound commands
deathaxe Aug 1, 2024
05b9ea5
[ShellScript] Refacotr case clauses
deathaxe Aug 1, 2024
c84458a
[ShellScript] Verify eval command higlighting
deathaxe Aug 1, 2024
02c7a78
[ShellScript] Fix single statement termination
deathaxe Aug 1, 2024
7dc59cd
[ShellScript] Fix indentation rules
deathaxe Aug 2, 2024
dacc3b8
[ShellScript] Syntax based folding
deathaxe Jul 26, 2024
536f44c
[ShellScript] Adjust completion rules
deathaxe Aug 2, 2024
8e4b0f7
[ShelScript] Adjust `in` keyword scope
deathaxe Aug 2, 2024
3941f47
[ShellScript] Simplify built-ins
deathaxe Jul 18, 2024
d939663
[ShellScript] Refactor context switch architecture
deathaxe Aug 3, 2024
adbb88c
[ShellScript] Reorganize variables
deathaxe Aug 3, 2024
3432c1c
[ShellScript] Tweak loop iterator context structure
deathaxe Aug 4, 2024
656378c
[ShellScript] Add command and time built-ins
deathaxe Aug 4, 2024
3c39ca0
[ShellScript] Add command modifiers
deathaxe Aug 4, 2024
500f712
[ShellScript] Add trap built-in
deathaxe Aug 4, 2024
5e21020
[ShellScript] Add Zsh Syntax
deathaxe Aug 1, 2024
d2b8e15
[Markdown] Adjust tests and add zsh code fences
deathaxe Aug 4, 2024
8ba9bf2
[ShellScript] Fix symbol definitions
deathaxe Aug 4, 2024
f31dca1
[ShellScript] Refactor HEREDOC
deathaxe Aug 4, 2024
2139db2
[ShellScript] Move variables main context to the bottom
deathaxe Aug 5, 2024
e311698
[ShellScript] Add basic completions
deathaxe Aug 2, 2024
f7663c8
[ShellScript] Allow overriding indentation restrictions
deathaxe Aug 6, 2024
58a3528
[Markdown] Improve embedded shells
deathaxe Aug 6, 2024
a86fb28
[ShellScript] Reorganize some variables
deathaxe Aug 6, 2024
ac39769
[ShellScript] Fix HEREDOCs in ZSH
deathaxe Aug 6, 2024
3e2a389
[ShellScript] Fix HERESTRING body
deathaxe Aug 6, 2024
28424dd
[ShellScript] Remove obsolete parameter expansion context
deathaxe Aug 6, 2024
ebd183c
[ShellScript] Exclude prototype from all string contexts
deathaxe Aug 6, 2024
dd8ed90
[ShellScript] Fix context order
deathaxe Aug 6, 2024
497e9d2
[ShellScript] Add special treatment of mapfile built-in
deathaxe Aug 7, 2024
6e9a4b3
[ShellScript] Tweak command reference scopes and symbols
deathaxe Aug 7, 2024
9783c6e
[ShellScript] Add special treatment for readarray built-in
deathaxe Aug 7, 2024
bd8a70c
[Markdown] Adjust syntax tests
deathaxe Aug 7, 2024
0662b92
[ShellScript] Reorganize bash built-in tests
deathaxe Aug 7, 2024
36b6740
[ShellScript] Scope quoted statements `meta.quoted`
deathaxe Aug 9, 2024
6b7e7ee
[ShellScript] Improve ZSH extended glob support
deathaxe Aug 7, 2024
8dbd66c
[ShellScript] Align pattern group scopes with RegExp syntax
deathaxe Aug 9, 2024
d6ae991
[ShellScript] Tidy up and simplify cmd-args contexts
deathaxe Aug 10, 2024
f0df84e
[ShellScript] Disable KSH_GLOB in ZSH
deathaxe Aug 10, 2024
3517b9f
[ShellScript] Refine case clause patterns
deathaxe Aug 10, 2024
15f1b68
[ShellScript] Refine pattern matching contexts
deathaxe Aug 10, 2024
981db42
[ShellScript] Simplify path patterns
deathaxe Aug 10, 2024
fae08a9
[ShellScript] Support interpolation in numbers
deathaxe Aug 10, 2024
a914281
[ShellScript] Refine tilde expansions termination
deathaxe Aug 11, 2024
49517f4
[ShellScript] Add a common word-end context
deathaxe Aug 11, 2024
6fb46fb
[ShellScript] Fix redirection stdio file descriptor
deathaxe Aug 11, 2024
00c7f84
[ShellScript] Special scope for /dev/null
deathaxe Aug 11, 2024
479b729
[ShellScript] Higher priority for inout redirections
deathaxe Aug 11, 2024
ec1e732
[ShellScript] Fix range vs. redirection in parameter expansions
deathaxe Aug 11, 2024
8937655
[ShellScript] Align glob operator scopes with regex
deathaxe Aug 11, 2024
9b31f0a
[ShellScript] Zsh qualifier ranges undergo arithmetic expansion
deathaxe Aug 11, 2024
f2c84db
[ShellScript] Remove redundant pattern
deathaxe Aug 11, 2024
ca8a444
[ShellScript] Fix Zsh glob qualifier detection in groups
deathaxe Aug 11, 2024
be6c34d
[ShellScript] Optimize list-end context
deathaxe Aug 14, 2024
01eb607
[ShellScript] Reuse variable-subscription
deathaxe Aug 12, 2024
917874f
[ShellScript] Refactor case clause pattern
deathaxe Aug 16, 2024
f62ec03
[ShellScript] Split compound command contexts
deathaxe Aug 12, 2024
6e22e15
[ShellScript] Refactor redirections
deathaxe Aug 12, 2024
133a3bf
[ShellScript] Add meta scope for variable assignments
deathaxe Aug 12, 2024
8fa9304
[ShellScript] Reorganize zsh pattern operators
deathaxe Aug 13, 2024
28b062d
[ShellScript] Improve builtin "read" argument highlighting
deathaxe Aug 18, 2024
033216d
[ShellScript] Restrict integer highlighting in literal string contexts
deathaxe Aug 19, 2024
19f494c
[ShellScript] Scope pre-/suffix of brace extensions string
deathaxe Aug 21, 2024
d6e147c
[ShellScript] Fix arithmetic vs. command expansions
deathaxe Sep 5, 2024
a2da391
[ShellScript]: Fix illegal pipe operators
deathaxe Aug 15, 2024
8f231ba
[ShellScript] More natural expansion context names
deathaxe Sep 9, 2024
b29ad25
[ShellScript] Fix ZSH glob range meta scope extends
deathaxe Sep 9, 2024
d243ff2
[ShellScript] Scope glob strings `meta.string.glob`
deathaxe Sep 22, 2024
ab67b7d
[ShellScript] Arithmetic expansions in subscriptions
deathaxe Sep 22, 2024
87b2a78
[Makefile] Move extended ShellScript syntax
deathaxe Sep 22, 2024
fdf73d4
[ShellScript] Add test patterns to common ZSH examples
deathaxe Sep 22, 2024
d76a689
[ShellScript] Fix redirection after function definition body
deathaxe Oct 12, 2024
21e865c
Merge branch 'master' into pr/shellscript/zsh
deathaxe Oct 13, 2024
5574d93
[ShellScript] Fix Groovy syntax tests
deathaxe Oct 13, 2024
8e2aa5f
[ShellScript] Fix built-in overrides
deathaxe Oct 23, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Groovy/tests/syntax_test_jenkins.Jenkinsfile
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ def call() {
// ^^^ meta.block.groovy meta.string.embedded-shell.groovy punctuation.definition.string.begin.groovy
// ^ meta.block.groovy meta.string.embedded-shell.groovy string.quoted.single.block.groovy source.shell.bash comment.line.number-sign.shell punctuation.definition.comment.shell
echo "hello ${world}"
// ^^^^ meta.block.groovy meta.string.embedded-shell.groovy string.quoted.single.block.groovy source.shell.bash meta.function-call.identifier.shell support.function.echo.shell
// ^^^^ meta.block.groovy meta.string.embedded-shell.groovy string.quoted.single.block.groovy source.shell.bash meta.function-call.identifier.shell support.function.shell
// ^ meta.interpolation.parameter.shell punctuation.definition.variable.shell
// ^ meta.interpolation.parameter.shell punctuation.section.interpolation.begin.shell
// ^^^^^ meta.interpolation.parameter.shell variable.other.readwrite.shell
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,7 @@ extends: Packages/ShellScript/Shell-Unix-Generic.sublime-syntax

contexts:

expansions-parameter:
- meta_prepend: true
parameter-expansions:
- include: Packages/Makefile/Makefile.sublime-syntax#variable-substitutions

string-prototype:
Expand Down
6 changes: 3 additions & 3 deletions Makefile/Makefile.sublime-syntax
Original file line number Diff line number Diff line change
Expand Up @@ -314,7 +314,7 @@ contexts:
- include: shell-content

shell-content:
- include: Packages/Makefile/Makefile Shell.sublime-syntax
- include: Packages/Makefile/Embeddings/Shell (for Makefile).sublime-syntax
apply_prototype: true

line-continuation:
Expand Down Expand Up @@ -660,13 +660,13 @@ contexts:
- match: \$(?=\$[{\w])
scope: constant.character.escape.makefile
push:
- include: scope:source.shell.bash#expansions-parameter
- include: scope:source.shell.bash#parameter-expansions
- match: ''
pop: 1
- match: \$(?=\$\()
scope: constant.character.escape.makefile
push:
- include: scope:source.shell.embedded.makefile#expansions-command
- include: scope:source.shell.embedded.makefile#command-expansions
- match: ''
pop: 1
- match: (\$)[[:alpha:]]
Expand Down
14 changes: 7 additions & 7 deletions Makefile/syntax_test_makefile.mak
Original file line number Diff line number Diff line change
Expand Up @@ -1001,7 +1001,7 @@ TESTTOOL = sh -c '\
fi' TESTTOOL
# ^^^ meta.string.makefile meta.interpolation.makefile
# ^^^^^^^^^ meta.string.makefile string.unquoted.makefile - meta.interpolation
# ^^ source.shell.embedded keyword.control.conditional.end.shell - source.shell source.shell
# ^^ source.shell.embedded keyword.control.conditional.endif.shell - source.shell source.shell
# ^ punctuation.section.interpolation.end.makefile


Expand All @@ -1021,23 +1021,23 @@ html:
shell_string_interpolation:
var1="double nquoted $(string) value"
# ^^^^^^^^^^^^^^^^ string.quoted.double.shell
# ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.function.body.makefile source.shell.embedded.makefile meta.string.shell
# ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.function.body.makefile source.shell.embedded.makefile meta.string.glob.shell
# ^^^^^^^^^ meta.interpolation
# ^^ keyword.other.block.begin.makefile
# ^^^^^^ variable.parameter.makefile
# ^ keyword.other.block.end.makefile
# ^^^^^^^ string.quoted.double.shell
var1='single nquoted $(string) value'
# ^^^^^^^^^^^^^^^^ string.quoted.single.shell
# ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.function.body.makefile source.shell.embedded.makefile meta.string.shell
# ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.function.body.makefile source.shell.embedded.makefile meta.string.glob.shell
# ^^^^^^^^^ meta.interpolation
# ^^ keyword.other.block.begin.makefile
# ^^^^^^ variable.parameter.makefile
# ^ keyword.other.block.end.makefile
# ^^^^^^^ string.quoted.single.shell
var1=unquoted\ $(string)\ value
# ^^^^^^^^^^ string.unquoted.shell
# ^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.function.body.makefile source.shell.embedded.makefile meta.string.shell
# ^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.function.body.makefile source.shell.embedded.makefile meta.string.glob.shell
# ^^^^^^^^^ meta.interpolation
# ^^ keyword.other.block.begin.makefile
# ^^^^^^ variable.parameter.makefile
Expand All @@ -1059,13 +1059,13 @@ foo:
# ^ constant.character.escape.makefile
# ^ punctuation
# ^ punctuation.section.interpolation.begin.shell
# ^^^^ support.function.echo.shell
# ^^^^ support.function.shell
# ^ constant.character.escape.makefile
# ^ punctuation.definition.variable.shell
# ^^^^^ variable.other.readwrite.shell
# ^^^^^ variable.language.builtin.shell

test "$$abc" = "$$def"
# ^ support.function.test.shell
# ^ support.function.shell
# ^^^^^^^ string.quoted.double.shell
# ^ constant.character.escape.makefile
# ^ punctuation.definition.variable.shell
Expand Down
41 changes: 41 additions & 0 deletions Markdown/Embeddings/Bash (for Markdown).sublime-syntax
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
%YAML 1.2
---
scope: source.shell.bash.embedded.markdown
version: 2
hidden: true

extends: Packages/ShellScript/Bash.sublime-syntax

contexts:
main:
- meta_include_prototype: false
# found shebang => normal script
- match: ^(?=\s*#!)
set: [statements, shebang]
# first non-comment line starts with `$` => interactive shell
- match: ^(?=\s*\$\s)
set: shell-interactive
# some script without shebang
- match: ^(?=\s*[^#])
set: statements
- include: comments

shell-interactive:
- match: ^\s*(\$)(?=\s)
captures:
1: comment.other.shell
embed: statements
escape: '{{no_escape_behind}}\n'

line-continuation-body:
- meta_prepend: true
# continuation line of interactive shells begin with `> `
- match: ^\s*(>)\s
captures:
1: comment.other.shell
pop: 1

variables:
# lazy escaping from heredoc as shell maybe indented
no_indent: ^\s*
tab_indent: ^\s*
9 changes: 9 additions & 0 deletions Markdown/Embeddings/Zsh (for Markdown).sublime-syntax
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
%YAML 1.2
---
scope: source.shell.zsh.embedded.markdown
version: 2
hidden: true

extends:
- Bash (for Markdown).sublime-syntax
- Packages/ShellScript/Zsh.sublime-syntax
21 changes: 9 additions & 12 deletions Markdown/Markdown.sublime-syntax
Original file line number Diff line number Diff line change
Expand Up @@ -1128,7 +1128,6 @@ contexts:
- include: fenced-rust
- include: fenced-scala
- include: fenced-shell
- include: fenced-shell-script
- include: fenced-sql
- include: fenced-tsx
- include: fenced-typescript
Expand Down Expand Up @@ -1931,43 +1930,41 @@ contexts:
- match: |-
(?x)
{{fenced_code_block_start}}
(?i:\s*(console|shell))
(?i:\s*(console|bash|shell(?:-script)?|sh))
{{fenced_code_block_trailing_infostring_characters}}
captures:
0: meta.code-fence.definition.begin.shell.markdown-gfm
2: punctuation.definition.raw.code-fence.begin.markdown
5: constant.other.language-name.markdown
6: comment.line.infostring.markdown
7: meta.fold.code-fence.begin.markdown
embed: scope:source.shell.interactive.markdown
embed: scope:source.shell.bash.embedded.markdown
embed_scope:
markup.raw.code-fence.shell.markdown-gfm
source.shell.interactive.markdown
source.shell.bash.embedded.markdown
escape: '{{fenced_code_block_escape}}'
escape_captures:
0: meta.code-fence.definition.end.shell.markdown-gfm
1: punctuation.definition.raw.code-fence.end.markdown
2: meta.fold.code-fence.end.markdown

fenced-shell-script:
- match: |-
(?x)
{{fenced_code_block_start}}
(?i:\s*(shell-script|sh|bash|zsh))
(?i:\s*(zsh))
{{fenced_code_block_trailing_infostring_characters}}
captures:
0: meta.code-fence.definition.begin.shell-script.markdown-gfm
0: meta.code-fence.definition.begin.shell.markdown-gfm
2: punctuation.definition.raw.code-fence.begin.markdown
5: constant.other.language-name.markdown
6: comment.line.infostring.markdown
7: meta.fold.code-fence.begin.markdown
embed: scope:source.shell.bash
embed: scope:source.shell.zsh.embedded.markdown
embed_scope:
markup.raw.code-fence.shell-script.markdown-gfm
source.shell.bash
markup.raw.code-fence.shell.markdown-gfm
source.shell.zsh.embedded.markdown
escape: '{{fenced_code_block_escape}}'
escape_captures:
0: meta.code-fence.definition.end.shell-script.markdown-gfm
0: meta.code-fence.definition.end.shell.markdown-gfm
1: punctuation.definition.raw.code-fence.end.markdown
2: meta.fold.code-fence.end.markdown

Expand Down
29 changes: 0 additions & 29 deletions Markdown/Shell (for Markdown).sublime-syntax

This file was deleted.

Loading