diff --git a/CHANGELOG.md b/CHANGELOG.md
index 18ef296..beb78db 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -7,6 +7,7 @@ Changelog
Improvements:
- Support the `[ ]` form of `test` (#8)
- Highlight a `~` in redirect paths
+- Distinguish arguments which might be paths with `meta.parameter.argument.path`
- Distinguish option and argument parameter types, and long and short option types (as well as the "end of options" option).
We now provide the following scopes:
- `meta.parameter.option.long`
diff --git a/README.md b/README.md
index 444a254..6d13f99 100644
--- a/README.md
+++ b/README.md
@@ -60,11 +60,11 @@ Exposed scopes
| Unquoted string | `meta.string.unquoted`
| File path (in redirection) | `meta.redirection.path`
| Variable expansion | `meta.variable-expansion` and `punctuation.definition.variable`
-| Process expansion | `meta.process-expansion` and `punctuation.definition.process`
+| Process expansion | `meta.parameter.argument.process-expansion` and `punctuation.definition.process`
| Command substitution | `meta.parens.command-substitution` and `punctuation.section.parens.begin`/`end`
| Index expansion | `meta.brackets.index-expansion` and `punctuation.section.brackets.begin`/`end`
| Brace expansion | `meta.braces.brace-expansion` and `punctuation.section.braces.begin`/`separator`/`end`
-| Home directory expansion | `meta.home-directory-expansion` and `keyword.operator.tilde`
+| Home directory expansion | `meta.parameter.argument.path` and `keyword.operator.tilde`
| Wildcard expansion | `meta.wildcard-expansion` and `keyword.operator.question-mark`/`single-star`/`double-star`
Contribution
diff --git a/Tools/syntax_test_fish.fish b/Tools/syntax_test_fish.fish
index 8baf870..e8eb57c 100644
--- a/Tools/syntax_test_fish.fish
+++ b/Tools/syntax_test_fish.fish
@@ -27,7 +27,7 @@ echo ~foo \~bar~\~ %foo \%bar%\%
#! ^^^^^^^^ meta.string.unquoted
#! ^ - keyword.operator.tilde
#! ^^ constant.character.escape
-#! ^^^^ meta.process-expansion
+#! ^^^^ meta.parameter.argument.process-expansion
#! ^ punctuation.definition.process
#! ^^^^^^^^ meta.string.unquoted
#! ^^ constant.character.escape
@@ -793,26 +793,26 @@ echo one{, ,\ }two
#! ^^ constant.character.escape
echo %"fish" one%two %%percent
-#! ^^^^^^^ meta.process-expansion
+#! ^^^^^^^ meta.parameter.argument.process-expansion
#! ^ punctuation.definition.process
#! ^^^^^^ string.quoted
#! ^^^^^^^ meta.string.unquoted
-#! ^^^^^^^^^ meta.process-expansion
+#! ^^^^^^^^^ meta.parameter.argument.process-expansion
#! ^ punctuation.definition.process
#! ^^^^^^^^ meta.string.unquoted
echo %fi\
sh>out
-#! <- meta.process-expansion
+#! <- meta.parameter.argument.process-expansion
#! ^^^ meta.redirection
echo %self foo %(set foo "fi"; echo $foo)sh "bar"
-#! ^^^^^ meta.process-expansion
+#! ^^^^^ meta.parameter.argument.process-expansion
#! ^ punctuation.definition.process
#! ^^^ meta.string.unquoted
#! ^ punctuation.definition.process
#! ^^^^^^^^^^^^^^^^^^^^^^^^^ meta.parens.command-substitution
-#! ^^ meta.process-expansion
+#! ^^ meta.parameter.argument.process-expansion
#! ^^^^^ string.quoted
echo %self>out
diff --git a/fish.YAML-tmLanguage b/fish.YAML-tmLanguage
index 0ac02a8..d63791d 100644
--- a/fish.YAML-tmLanguage
+++ b/fish.YAML-tmLanguage
@@ -135,34 +135,41 @@ repository:
comment: This rule must be entirely standalone because it is used in scopes where parameters starting with hyphens are explicitly interpreted as arguments rather than as options
patterns:
- comment: A parameter is a fundamental unit of a command call, defined as a sequence of non-operator characters separated by unescaped and unscoped whitespace
- name: meta.parameter.argument.fish
begin: (?![\s;&)|<>^])
comment: Begin arg if it does not precede whitespace or an operator
end: (?=[\s;&)|<>])
comment: End arg if it precedes whitespace or operators (excluding stderr redirect '^' due to a fish quirk)
patterns:
- - comment: Home directory expansion only occurs if the '~' is at the front of the argument
- name: meta.string.unquoted.fish meta.home-directory-expansion.fish keyword.operator.tilde.fish
- match: \~
-
- comment: Process expansion only occurs if the '%' is at the front of the argument, and continues for the entire argument
- name: meta.process-expansion.fish
+ name: meta.parameter.argument.process-expansion.fish
begin: \%
beginCaptures:
'0': {name: meta.string.unquoted.fish punctuation.definition.process.fish}
end: (?=[\s;&)|<>])
patterns:
- comment: Match special process names. By a convention that I'm making up, scope them as a type of variable
- name: variable.language.fish meta.string.unquoted.fish
+ name: meta.string.unquoted.fish variable.language.fish
match: (?:self|last)(?=$|[\s;&)|<>])
- include: '#parameter-patterns'
- - comment: Treat a sequence of integers (with possible sign and decimal separator) as a standalone constant. Do this separate to the #string-unquoted-pattens rule so we can ensure it is a string solely of numbers
- name: meta.string.unquoted.fish constant.numeric.fish
+ - comment: Treat a sequence of integers (with possible sign and decimal separator) as a standalone constant. Do this separate to the #string-unquoted-patterns rule so we can ensure it is a string solely of numbers
+ name: meta.parameter.argument.numeric.fish meta.string.unquoted.fish constant.numeric.fish
match: (?:[+-]?)(?:[0-9]+\.?[0-9]*|[0-9]*\.?[0-9]+)(?=$|[\s;&)|<>])
- - comment: Use standard parameter patterns exclusively for the remainder of the argument
+ - comment: This scope can be used by plugins to locate arguments which don't *start* with command substitution or variable expansion and may directly resolve to file paths. Of course, they could have command substitution or variable expansion further on in them, but looking ahead for that too is nontrivial
+ name: meta.parameter.argument.path.fish
+ begin: (?![\s($])
+ end: (?=[\s;&)|<>])
+ patterns:
+ - comment: Home directory expansion only occurs if the '~' is at the front of the argument, so check it first
+ name: meta.string.unquoted.fish keyword.operator.tilde.fish
+ match: \~
+
+ - include: '#parameter-patterns'
+
+ - comment: Use standard parameter patterns for whatever doesn't match the above
+ name: meta.parameter.argument.fish
begin: (?!\s)
end: (?=[\s;&)|<>])
patterns:
diff --git a/fish.tmLanguage b/fish.tmLanguage
index 84d33ed..22dc614 100644
--- a/fish.tmLanguage
+++ b/fish.tmLanguage
@@ -108,18 +108,8 @@
End arg if it precedes whitespace or operators (excluding stderr redirect '^' due to a fish quirk)
end
(?=[\s;&)|<>])
- name
- meta.parameter.argument.fish
patterns
-
- comment
- Home directory expansion only occurs if the '~' is at the front of the argument
- match
- \~
- name
- meta.string.unquoted.fish meta.home-directory-expansion.fish keyword.operator.tilde.fish
-
begin
\%
@@ -136,7 +126,7 @@
end
(?=[\s;&)|<>])
name
- meta.process-expansion.fish
+ meta.parameter.argument.process-expansion.fish
patterns
@@ -145,7 +135,7 @@
match
(?:self|last)(?=$|[\s;&)|<>])
name
- variable.language.fish meta.string.unquoted.fish
+ meta.string.unquoted.fish variable.language.fish
include
@@ -159,15 +149,42 @@
match
(?:[+-]?)(?:[0-9]+\.?[0-9]*|[0-9]*\.?[0-9]+)(?=$|[\s;&)|<>])
name
- meta.string.unquoted.fish constant.numeric.fish
+ meta.parameter.argument.numeric.fish meta.string.unquoted.fish constant.numeric.fish
+
+
+ begin
+ (?![\s($])
+ comment
+ This scope can be used by plugins to locate arguments which don't *start* with command substitution or variable expansion and may directly resolve to file paths. Of course, they could have command substitution or variable expansion further on in them, but looking ahead for that too is nontrivial
+ end
+ (?=[\s;&)|<>])
+ name
+ meta.parameter.argument.path.fish
+ patterns
+
+
+ comment
+ Home directory expansion only occurs if the '~' is at the front of the argument, so check it first
+ match
+ \~
+ name
+ meta.string.unquoted.fish keyword.operator.tilde.fish
+
+
+ include
+ #parameter-patterns
+
+
begin
(?!\s)
comment
- Use standard parameter patterns exclusively for the remainder of the argument
+ Use standard parameter patterns for whatever doesn't match the above
end
(?=[\s;&)|<>])
+ name
+ meta.parameter.argument.fish
patterns