1. 4FIPS
  2. PHOTOS
  3. VIDEOS
  4. APPS
  5. CODE
  6. FORUMS
  7. ABOUT
%YAML 1.2
---
# ==============================================================================
# fs_agenda Syntax Definition for Sublime Text
# File extensions: *.age, *.age.txt
# Disclaimer: This project was largely vibe-coded using Google Search's AI Mode.
# [VER 1.261126.0 BY 4FIPS.COM, MIT-LICENSED, https://forums.4fips.com/viewtopic.php?t=6931]
# ==============================================================================
name: fs_agenda
file_extensions:
  - age
  - age.txt
scope: source.fs-agenda

contexts:
  main:
    # 1. Auto-generated Agenda Block (░ ... ░)
    - match: '^\s*░{10,}\s*$'
      scope: punctuation.definition.block.agenda.fs-agenda
      push: inside-agenda-block

    # 2. Comment lines
    - match: '^\s*#.*$'
      scope: comment.line.number-sign.fs-agenda

    # 3. Completed / Checked-off lines ([x] or [X]) -> dimmed
    - match: '^\s*\[[xX]\]'
      scope: punctuation.definition.checkbox.done.fs-agenda
      push: done-line

    # 4. Active lines ([ ])
    - match: '^\s*\[ \]'
      scope: keyword.operator.checkbox.open.fs-agenda
      push: active-line

    # 5. Any other non-blank line is a syntax error
    - match: '^\s*\S.*$'
      scope: invalid.illegal.unrecognized-line.fs-agenda

  # ----------------------------------------------------------------------------
  # Inside the Auto-Generated Agenda Block
  # ----------------------------------------------------------------------------
  inside-agenda-block:
    # Closing Agenda banner
    - match: '^\s*░{10,}\s*$'
      scope: punctuation.definition.block.agenda.fs-agenda
      pop: true

    # Inner Parse Errors box (█ ... █)
    - match: '^\s*█{10,}\s*$'
      scope: markup.bold.error-banner.fs-agenda
      push: inside-error-banner

    # Section labels (OVERDUE, BACKLOG, LATER)
    - match: '^(OVERDUE|BACKLOG|LATER)\b'
      scope: entity.name.section.fs-agenda

    # ISO Week divider (--- Week 49 ---)
    - match: '^---\s+Week\s+\d+\s+-+$'
      scope: comment.line.week-divider.fs-agenda

    # Day headers in the 7-day table (e.g., "Thu 26 Nov  TODAY :" or "Sat 28 Nov    +2d :")
    - match: '^(Mon|Tue|Wed|Thu|Fri|Sat|Sun)\s+\d{2}\s+[A-Za-z]{3}'
      scope: entity.name.function.day-header.fs-agenda

    - match: '\bTODAY\b'
      scope: constant.language.today.fs-agenda

    # Relative day offsets (-11d, +2d, +19d)
    - match: '\(-\d+d\)'
      scope: invalid.deprecated.overdue-offset.fs-agenda
    - match: '\(\+\d+d\)'
      scope: constant.numeric.upcoming-offset.fs-agenda
    - match: '\+\d+d(?=\s*:)'
      scope: constant.numeric.table-offset.fs-agenda

    # Dates inside Agenda
    - match: '\b\d{4}-\d{2}-\d{2}\b'
      scope: constant.numeric.date.fs-agenda

    # Overdue / Event / Task bullets inside Agenda
    - match: '(?<=:\s\s)!'
      scope: keyword.control.overdue-bullet.fs-agenda
    - match: '(?<=:\s\s)\*'
      scope: keyword.operator.event-bullet.fs-agenda

    # Occurrence counters (#8, #31) and recurrence badges ([1y], [1m])
    - match: '#\d+\b'
      scope: constant.numeric.count.fs-agenda
    - match: '\[\d+[ymwd]\]'
      scope: storage.type.repeat.fs-agenda

    # @tags inside Agenda
    - match: '@[A-Za-z0-9_-]+'
      scope: entity.name.tag.fs-agenda

    # Line jump references (:20) or (file.age:20)
    - match: '\((?:[^():]+)?:\d+\)\s*$'
      scope: markup.underline.link.line-ref.fs-agenda

  inside-error-banner:
    - match: '^\s*█{10,}\s*$'
      scope: markup.bold.error-banner.fs-agenda
      pop: true
    - match: 'PARSE ERRORS.*$'
      scope: keyword.control.error-title.fs-agenda
    - match: '\((?:[^():]+)?:\d+\)'
      scope: markup.underline.link.line-ref.fs-agenda
    - match: '->.*$'
      scope: string.unquoted.error-source.fs-agenda
    - match: '.+'
      scope: variable.parameter.error-detail.fs-agenda

  # ----------------------------------------------------------------------------
  # Completed Line ([x] ...)
  # ----------------------------------------------------------------------------
  done-line:
    - match: '$'
      pop: true
    - match: '.*'
      scope: comment.line.completed-task.fs-agenda

  # ----------------------------------------------------------------------------
  # Active Line ([ ] ...)
  # ----------------------------------------------------------------------------
  active-line:
    - match: '$'
      pop: true

    # Leading ISO date (YYYY-MM-DD)
    - match: '(?<=\]\s)\s*\d{4}-\d{2}-\d{2}\b'
      scope: constant.numeric.date.fs-agenda

    # Malformed date right after checkbox (e.g., 2026-2-5)
    - match: '(?<=\]\s)\s*\d{4}-\d{1,2}-\d{1,2}\b'
      scope: invalid.illegal.bad-date.fs-agenda

    # Inline @tags inside title
    - match: '(?<!\S)@[A-Za-z0-9_-]+'
      scope: entity.name.tag.fs-agenda

    # Modifier block {...} at the end of the line
    - match: '\{'
      scope: punctuation.section.braces.begin.fs-agenda
      push: modifier-block

    # Stray closing brace outside block
    - match: '\}'
      scope: invalid.illegal.stray-brace.fs-agenda

  # ----------------------------------------------------------------------------
  # Inside {...} Modifier Block
  # ----------------------------------------------------------------------------
  modifier-block:
    # Closing brace at end of line
    - match: '\}(?=\s*$)'
      scope: punctuation.section.braces.end.fs-agenda
      pop: true

    # Closing brace followed by trailing garbage -> error
    - match: '\}.*$'
      scope: invalid.illegal.trailing-after-braces.fs-agenda
      pop: true

    # Unclosed brace at end of line -> error
    - match: '$'
      scope: invalid.illegal.unclosed-brace.fs-agenda
      pop: true

    # Valid key:value modifiers
    - match: '\btype:(?:event|task)\b'
      scope: storage.type.modifier.fs-agenda
    - match: '\bevery:[1-9]\d*[ymwd]\b'
      scope: constant.numeric.interval.fs-agenda
    - match: '\bshow:(?:age|count)\b'
      scope: support.function.show.fs-agenda
    - match: '\bwarn:\d+d\b'
      scope: keyword.other.warn.fs-agenda
    - match: '\buntil:\d{4}-\d{2}-\d{2}\b'
      scope: constant.numeric.until-date.fs-agenda
    - match: '\btag:[A-Za-z0-9_-]+\b'
      scope: entity.name.tag.modifier.fs-agenda

    # Any other non-whitespace token inside {...} is invalid
    - match: '\S+'
      scope: invalid.illegal.unknown-modifier.fs-agenda