%YAML 1.2
---
# Git Rebase Todo syntax highlighting for Fresh editor
# Supports interactive rebase commands
name: Git Rebase Todo
file_extensions: []
scope: source.git-rebase-todo

contexts:
  main:
    - include: comments
    - include: commands

  comments:
    # Comment lines starting with #
    - match: '^#.*$'
      scope: comment.line.number-sign.git-rebase

  commands:
    # pick/p - use commit
    - match: '^(p(?:ick)?)\s+([0-9a-fA-F]+)\s+(.*)'
      captures:
        1: keyword.control.pick.git-rebase
        2: constant.numeric.hash.git-rebase
        3: string.unquoted.message.git-rebase

    # reword/r - use commit but edit message
    - match: '^(r(?:eword)?)\s+([0-9a-fA-F]+)\s+(.*)'
      captures:
        1: keyword.control.reword.git-rebase
        2: constant.numeric.hash.git-rebase
        3: string.unquoted.message.git-rebase

    # edit/e - use commit but stop for amending
    - match: '^(e(?:dit)?)\s+([0-9a-fA-F]+)\s+(.*)'
      captures:
        1: keyword.control.edit.git-rebase
        2: constant.numeric.hash.git-rebase
        3: string.unquoted.message.git-rebase

    # squash/s - meld into previous commit
    - match: '^(s(?:quash)?)\s+([0-9a-fA-F]+)\s+(.*)'
      captures:
        1: keyword.control.squash.git-rebase
        2: constant.numeric.hash.git-rebase
        3: string.unquoted.message.git-rebase

    # fixup/f - like squash but discard message
    - match: '^(f(?:ixup)?)\s+([0-9a-fA-F]+)\s+(.*)'
      captures:
        1: keyword.control.fixup.git-rebase
        2: constant.numeric.hash.git-rebase
        3: string.unquoted.message.git-rebase

    # drop/d - remove commit
    - match: '^(d(?:rop)?)\s+([0-9a-fA-F]+)\s+(.*)'
      captures:
        1: keyword.control.drop.git-rebase
        2: constant.numeric.hash.git-rebase
        3: string.unquoted.message.git-rebase

    # exec/x - run command
    - match: '^(x|exec)\s+(.*)'
      captures:
        1: keyword.control.exec.git-rebase
        2: string.unquoted.command.git-rebase

    # break/b - stop here
    - match: '^(b(?:reak)?)\s*$'
      scope: keyword.control.break.git-rebase

    # label - label current HEAD
    - match: '^(label)\s+(\S+)'
      captures:
        1: keyword.control.label.git-rebase
        2: entity.name.label.git-rebase

    # reset - reset HEAD to label
    - match: '^(reset)\s+(\S+)'
      captures:
        1: keyword.control.reset.git-rebase
        2: entity.name.label.git-rebase

    # merge - create merge commit
    - match: '^(merge)\s+(-[Cc]\s+[0-9a-fA-F]+\s+)?(\S+)(?:\s+#\s+(.*))?'
      captures:
        1: keyword.control.merge.git-rebase
        2: constant.numeric.hash.git-rebase
        3: entity.name.label.git-rebase
        4: string.unquoted.message.git-rebase

    # update-ref - track ref update
    - match: '^(update-ref)\s+(\S+)'
      captures:
        1: keyword.control.update-ref.git-rebase
        2: entity.name.ref.git-rebase

    # noop - do nothing (generated by git)
    - match: '^(noop)\s*$'
      scope: keyword.control.noop.git-rebase
