Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* [ShellScript] Fix job built-ins This commit... 1. adds missing -f and -p options for wait built-in 2. adds dedicated tests for job built-in commands 3. refactors job variable tests by replacing `fg` command by `:` dummy to align them with majority of other variable tests * [ShellScript] Fix brace expansions This commit fixes support for brace expansions according to bash syntax specs. Former `number-range` was just a special case for what brace expansions can do. * [ShellScript] Fix tilde expansions * [ShellScript] Refactor parameter expansions This commit ... 1. applies structural changes, required for ZSH. 2. fixes various parameter expansion bugs related with special parameters e.g. `${$}`, `${?}`, ... 3. fixes advanced tilde expansions such as `~name/` or `~+/` In general it means to introduce contexts and rules to scope expansions more precisely and detailed. * [ShellScript] Refactor redirections * [ShellScript] Refactor subscriptions * [ShellScript] Fix function identifiers This commit removes quote-removal from function and alias identifiers as it is not supported by Bash. Function identifiers must be unquoted literals. * [ShellScript] Exclude linefeed from continuation punctuation * [ShellScript] Replace various anonymous contexts in Bash This commit makes it easier to extend contexts in inherited syntax definitions. * [ShellScript] Scope function body meta.block This commit scopes function bodies with a commonly used meta scope in favor of Bash's "compound" command as preparation for other shells, which follow closer to other programming languages. It removes redirections from context stack as those are handled globally. * [ShellScript] Refactor case statement contexts This commit applies required changes to support ZSH case statements, which may use curly braced code blocks as in C, which didn't work well with previous meta scope structure. * [ShellScript] Add paths patterns * [ShellScript] Refactor command arguments' word boundaries This commit... 1. refactors how word boundaries and quotes are treated. Motivation: A reliably distinction between tilde-expansions and logic operators is required in ZSH pattern matching to support the following: cmd ~/path/*~*.com ^ operator ^ tilde expansion 2. assigns `string` scope to all suitable strings and patterns to enable color schemes to more clearly distinguish them from variables. Note: Aligns Bash with "Batch File" syntax. 3. refactors command argument list termination Replace clunky and messy "boilerplate" contexts with proper "cmd-args-end". Note: Aligns Bash with "Batch File" syntax. * [ShellScript] Reorganize literals * [ShellScript] Special echo treatment Everything between options and end of command is a string, regardless quotation. This commit therefore introduces special contexts for `echo` builtin. * [ShellScript] Tweak builtin test command arguments This commit... 1. fixes [ command termination behavior - terminate at \n ; && or || as normal `test` builtin 2. prefers scoping < > as comparison operator as it is more likely to be valid than redirections. Note: May need further refinements 3. highlight unquoted ; illegal in [[ ... ]] compound test expressions 4. fixes word boundaries of strings withing test expressions * [ShellScript] Remove obsolete brace expansion contexts * [ShellScript] Scope built-in variables This commit scopes all pre-defined built-in variables and distinguishes them from special variables such as `$0` or `$*`. Fixes an issue with `$_` vs. `$$_` highlighting. see: https://www.gnu.org/software/bash/manual/bash.html#Shell-Variables * [ShellScript] Reorganize expressions Move up expressions and operators contexts. * [ShellScript] Reorganize literals This commit moves literals, strings and pattern matching contexts up, right after heredocs. * [ShellScript] Add arithmetic highlighting in assignment values This commit... 1. enables support for correctly scoping literal and arithmetic assignment values in `declare` commands and its friends. 2. fixes unsupported nested `(...)` in value sequences. The following is illegal `var=(foo (bar baz))`. 3. distinguishes option assignment values and variable assignment values. Only the latter supports value sequences wrapped in parens. * [ShellScript] Reorganize variables * [ShellScript] Tweak number word breaks This commit... 1. drops leading `\b` from `numbers`'s patterns as proper global word boundary checks are available. 2. treat numbers as words, consuming everything until word boundary and scope it illegal if not valid part of a number. * [ShellScript] Avoid duplicate patterns in statement 1. `comments` is not required 2. `line-continuations` is already provided by `eol-pop` * [ShellScript] Fix comments after heredoc tags * [ShellScript] Reorganize prototypes at the bottom * [ShellScript] Remove obsolete compound args contexts Only redirections are allowed after compound commands, which is already satisfied/handled via global statements context. * [ShellScript] Simplify coproc * [ShellScript] Refactor tilde interpolation scopes 1. always clear parent scope 2. scope username `constant.other` * [ShellScript] Align illegal token scopes Use already existing `invalid.illegal.unexpected-token.shell` * [ShellScript] Simplify alias meta scope * [ShellScript] Simplify declaration meta scope * [ShellScript] Refactor anonymous function definitions This commit... 1. scopes anonymous functions `meta.function-call meta.function.anonymous` as those are immediately called. 2. allows arguments after function body * [ShellScript] Refactor command arguments This commit adjusts builtin commands' argument contexts so they follow the same context structure, used by cmd-basic - means: dedicated cmd-args-meta context is used to apply meta.function-call.arguments scope. Hence eoc-pop2 and eol-pop2 become obsolete as all commands share same structure. * [ShellScript] Add missing option word boundaries * [ShellScript] Fix for arguments * [ShellScript] Simplify arithmetic command We have enough context to no longer need to rely on lookahead for closing )). * [ShellScript] Refactor arithmetic expressions This commit... 1. treats `let ...` statement as arithmetic variable declaration as this is what it is most likely used for. 2. drops `cmd-test` and treats arguments as plain arithmetic expressions. Actually let args are equal to content of (( ... )) compound commands according to Bash Manual. 3. refactors quoted vs. unquoted expressions * [ShellScript] Refactor conditional compound commands This commit... 1. applies `meta.compound.conditional` to `[ .. ]` and `[[ .. ]]` expressions 2. scopes brackets `punctuation.section.compound`. * [ShellScript] Refactor compound commands This commit applies `meta.compound.command` to compound commands to distinguish them via level-3 scope name from the others. * [ShellScript] Refacotr case clauses This commit... 1. scopes case statements `meta.statement.case` 2. scopes case clauses `meta.clause.[pattern|body]` 3. scopes case pattern parens `punctuation.definition.pattern.[begin|end]` ... in order to prepare for syntax based folding and align with scope naming guidelines with regards to punctuation. * [ShellScript] Verify eval command higlighting * [ShellScript] Fix single statement termination * [ShellScript] Fix indentation rules This commit... 1. adds indentation rules for case clauses 2. fixes indentation rules for if statements 3. adds indentation tests 4. adjusts code style of indentation rules * [ShellScript] Syntax based folding * [ShellScript] Adjust completion rules This commit cancels completions immediately after each reserved word to 1. give snippets precedence over completions 2. prefer enter adding a linefeed rather than committing a completion * [ShelScript] Adjust `in` keyword scope This commit scopes `in` as `keyword.operator.iterator`. * [ShellScript] Simplify built-ins This commit drops all command specific contexts and thus highlighting, because a syntax definition is not a linter and thus doesn't need to highlight unsupported command arguments `illegal`. That's cumbersome to maintain for multiple shell dialects and likely to fail once shells evolve. Therefore only syntactically important special cases are kept untouched. * [ShellScript] Refactor context switch architecture This commit... 1. `set`s command arguments' contexts onto stack rather than `pushing` them. 2. adjusts everything for it to work. Results: - a re-usable `statement` context, which consumes a single command and its arguments. - syntax cache size is reduced from 110kB to 88kB by this change - switching contexts of commands to push into if...else blocks etc. becomes much cheaper with regards to compiled syntax size. * [ShellScript] Reorganize variables * [ShellScript] Tweak loop iterator context structure This commit... 1. adds meta scopes to loop control statements 2. restricts loop iterator to single token * [ShellScript] Add command and time built-ins * [ShellScript] Add command modifiers * [ShellScript] Add trap built-in * [ShellScript] Add Zsh Syntax This commit... 1. reorganizes ShellScript package by moving all dialect specific files into separate sub directories, while maintaining only syntax definitions and basic sublime-... files in the top-level directory. That's required for maintainability and to keep track which meta files address certain dialects. - Shell: targets all shells - Bash: bash specific meta-data - Zsh: zsh specific meta-data 2. Adds Zsh syntax definition, indentation rules, ... * [Markdown] Adjust tests and add zsh code fences * [ShellScript] Fix symbol definitions * [ShellScript] Refactor HEREDOC This commit... 1. implements heredocs by top-most `embed...escape` pattern. This... - reduces compiled syntax cache size from 100kB to 90kB - reliably terminates heredoc strings with a single `escape` pattern - reduces syntax definition complexity and repetitions 2. restricts `meta.string.heredoc` scope to the string part excluding lines of opening and closing HEREDOC tags. That's required for herdoc specific indentation rules. * [ShellScript] Move variables main context to the bottom * [ShellScript] Add basic completions * [ShellScript] Allow overriding indentation restrictions This commit adds `tab_indent` and `no_indent` variables, which can be used by extending syntaxes to easily remove indentation restrictions. * [Markdown] Improve embedded shells This commit... 1. merges code blocks with shell-script and interactive shells. Both now use the same extended syntax, which detects interactive shell by checking the first lines of code. 2. implements lazy indentation for shebang and HEREDOCs to scope them correctly, even if fenced code block is indented. * [ShellScript] Reorganize some variables * [ShellScript] Fix HEREDOCs in ZSH * [ShellScript] Fix HERESTRING body This commit ensures the word after `<<<` operator is always scoped plain string without pattern matching or globbing being applied. That wasn't the case in assignment statements before. * [ShellScript] Remove obsolete parameter expansion context * [ShellScript] Exclude prototype from all string contexts ... to prefer and enforce usage of `string-prototype`. * [ShellScript] Fix context order * [ShellScript] Add special treatment of mapfile built-in * [ShellScript] Tweak command reference scopes and symbols This commit... 1. introduces a common `meta.command` scope applied to function calls and function name references. 2. adjusts reference definitions accordingly. Goal is a common and unique scope to target function or command references. * [ShellScript] Add special treatment for readarray built-in The command equals `mapfile`. * [Markdown] Adjust syntax tests * [ShellScript] Reorganize bash built-in tests - add command arguments call spec to comments - sort builtin and command tests between alias and declare alphabetically * [ShellScript] Scope quoted statements `meta.quoted` Align with quoted expressions * [ShellScript] Improve ZSH extended glob support * [ShellScript] Align pattern group scopes with RegExp syntax * [ShellScript] Tidy up and simplify cmd-args contexts * [ShellScript] Disable KSH_GLOB in ZSH * [ShellScript] Refine case clause patterns This commit... 1. enforces KSH style pattern groups in Bash's case clauses by removing simple parenthesized groups' support. This style is only valid in ZSH. 2. terminate case patterns at eol, if not starting with `(`. 3. handle the tricky case in ZSH of possibly unbalanced parentheses in case clause patterns: - `( group ) pattern ) statements ;;` - `( ( group ) pattern ) statements ;;` * [ShellScript] Refine pattern matching contexts This commit ... 1. introduce a `pattern-common` context for common patterns, which are valid in all sorts and locations of patterns. 2. modifies how `meta.group.regexp` is applied to reduce requirement of duplicated scope names in punctuation patterns. * [ShellScript] Simplify path patterns * [ShellScript] Support interpolation in numbers This commit add support for variable expansion in number to support some examples illustrated in pure bash bible, which convert colors to RGB. ((r=16#${_:0:2},g=16#${_:2:2},b=16#${_:4:2})) Illegal highlighting is dropped, but that's probably even more reliable, especially in scenarios of unknown delimiter or terminator characters. TODO: ZSH floating points are not covered, yet. * [ShellScript] Refine tilde expansions termination This commit adds escaped slash to tilde-expansion terminators. Actually Bash and ZSH behave different here. Bash treats whole string literal, if escaped slash follows tilde. `~\/*` => `~/*` Zsh performs full filename expansion `~\/*` => `/home/<user>/file1 /home/<user>/file2 ...` This commit treats both equally as Bash behavior required to distinguish all patterns in all situations for proper tilde expansion in order to decide whether to highlight subsequent patterns. * [ShellScript] Add a common word-end context Handle word-termination and line continuation in common re-usable context. * [ShellScript] Fix redirection stdio file descriptor * [ShellScript] Special scope for /dev/null * [ShellScript] Higher priority for inout redirections Make sure not to miss <>path over <path * [ShellScript] Fix range vs. redirection in parameter expansions This commit separates zsh glob range (`<1-10>`) patterns into those, which... 1. are used in contexts without redirection support, such as parameter expansion patterns. Incomplete or malformed ranges are scoped literal in parameter expansions. 2. need distinction between redirections and glob ranges. Word related contexts are popped off stack before metachar `<`. Hence each glob range starts a new word. Range detection is restricted to require exactly `< number - number >`, to avoid false positives, especially with stdio redirections like `< -`. In ambiguous situation of `<->`, a range is preferred. This change also fixes scoping of leading and trailing numbers, which are now scoped `meta.string`. * [ShellScript] Align glob operator scopes with regex * [ShellScript] Zsh qualifier ranges undergo arithmetic expansion * [ShellScript] Remove redundant pattern * [ShellScript] Fix Zsh glob qualifier detection in groups This commit restricts zsh glob qualifiers to unquoted top-level patterns. They are not valid in groups, but in array initialization lists. * [ShellScript] Optimize list-end context - removes duplicate `line-continuations` includes - moves `comments` include to `list-end` as it is commonly required * [ShellScript] Reuse variable-subscription This commit just saves some lines of code. * [ShellScript] Refactor case clause pattern This commit turns case clause patterns into a pattern list. It means, patterns may be surrounded by whitespace. * [ShellScript] Split compound command contexts Prepare to re-use body parts of compound commands, individually. * [ShellScript] Refactor redirections Redirections can appear everywhere. As for numbers or strings, a popping version of `redirection` is needed for e.g. assignment r-values. Herestrings are also scoped `meta.redirection` as of this commit. * [ShellScript] Add meta scope for variable assignments May help to implement goto definition for variable bindings * [ShellScript] Reorganize zsh pattern operators * [ShellScript] Improve builtin "read" argument highlighting * [ShellScript] Restrict integer highlighting in literal string contexts Numbers in command arguments are mainly guesswork. Bash/Zsh treat them string, but this syntax scopes valid looking numbers constant.number as it is what users might mainly expect. * [ShellScript] Scope pre-/suffix of brace extensions string * [ShellScript] Fix arithmetic vs. command expansions Fixes #4033 * [ShellScript]: Fix illegal pipe operators This commit ... 1. adds contexts to scope pipe operators illegal within lists, groups and tests. 2. handles the tricky part to distinguish `<1-2>` range operators at the beginning or within expansions, patterns or groups from redirections and literal scoped or illegal pipe operators, while maintaining word boundaries. * [ShellScript] More natural expansion context names * [ShellScript] Fix ZSH glob range meta scope extends * [ShellScript] Scope glob strings `meta.string.glob` This commit assigns `meta.string.glob` scope to strings, which support filename expansions. * [ShellScript] Arithmetic expansions in subscriptions Variable subscriptions undergo arithmetic expansion. * [Makefile] Move extended ShellScript syntax * [ShellScript] Add test patterns to common ZSH examples * [ShellScript] Fix redirection after function definition body * [ShellScript] Fix Groovy syntax tests * [ShellScript] Fix built-in overrides This commit reorganizes statement contexts for built-in commands to be augment-able by local function definitions, while keeping higher priority of reserved words. Reserved words, like `if`, `case`, ... can not be used as identifier for local function definitions, but all other built-in commands can be. As a result `def-anonymous` and `def-function` contexts can be merged. `cmd-coproc` is re-defined as kind of function definition under `def-coproc`. The token `time` is moved to `cmd-control` context and scoped `keyword.control` as it is a reserved word.
- Loading branch information