# zsh-users/zsh-syntax-highlighting architecture

> Architecture diagram of the GitHub repository zsh-users/zsh-syntax-highlighting, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-11-09). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/zsh-users/zsh-syntax-highlighting
- Repository: https://github.com/zsh-users/zsh-syntax-highlighting

## Overview

zsh-syntax-highlighting adds Fish-like syntax highlighting to commands typed at an interactive Zsh prompt. The documented flow is that ZLE provides the current command-line buffer to a registered hook, and pluggable highlighters compute highlighting for that buffer. The README documents the hook behavior and plugin model, but no source excerpts were provided, so internal dispatch among highlighters is not asserted.

Main entry points: [`zsh-syntax-highlighting.zsh`](https://github.com/zsh-users/zsh-syntax-highlighting/blob/master/zsh-syntax-highlighting.zsh) (ZLE Hook), [`highlighters/main/main-highlighter.zsh`](https://github.com/zsh-users/zsh-syntax-highlighting/blob/master/highlighters/main/main-highlighter.zsh) (Main Highlighter), [`highlighters/brackets/brackets-highlighter.zsh`](https://github.com/zsh-users/zsh-syntax-highlighting/blob/master/highlighters/brackets/brackets-highlighter.zsh) (Bracket Highlighter), [`highlighters/cursor/cursor-highlighter.zsh`](https://github.com/zsh-users/zsh-syntax-highlighting/blob/master/highlighters/cursor/cursor-highlighter.zsh) (Cursor Highlighter)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_integration["Zsh Integration"]
  node_zle["Zsh Line Editor"]
  node_entry["ZLE Hook"]
end

subgraph group_highlighters["Highlighter Plugins"]
  node_main["Main Highlighter"]
  node_brackets["Bracket Highlighter"]
  node_cursor["Cursor Highlighter"]
  node_line["Line Highlighter"]
  node_pattern["Pattern Highlighter"]
  node_regexp["Regexp Highlighter"]
  node_root["Root Highlighter"]
end

subgraph group_display["Prompt Output"]
  node_terminal["Interactive Terminal"]
end

node_user(("Shell User"))

node_user -->|"types command"| node_zle
node_zle -->|"runs hook"| node_entry
node_entry -.->|"uses plugin"| node_main
node_entry -.->|"uses plugin"| node_brackets
node_entry -.->|"uses plugin"| node_cursor
node_entry -.->|"uses plugin"| node_line
node_entry -.->|"uses plugin"| node_pattern
node_entry -.->|"uses plugin"| node_regexp
node_entry -.->|"uses plugin"| node_root
node_entry -->|"applies highlighting"| node_terminal

click node_entry "https://github.com/zsh-users/zsh-syntax-highlighting/blob/master/zsh-syntax-highlighting.zsh"
click node_main "https://github.com/zsh-users/zsh-syntax-highlighting/blob/master/highlighters/main/main-highlighter.zsh"
click node_brackets "https://github.com/zsh-users/zsh-syntax-highlighting/blob/master/highlighters/brackets/brackets-highlighter.zsh"
click node_cursor "https://github.com/zsh-users/zsh-syntax-highlighting/blob/master/highlighters/cursor/cursor-highlighter.zsh"
click node_line "https://github.com/zsh-users/zsh-syntax-highlighting/blob/master/highlighters/line/line-highlighter.zsh"
click node_pattern "https://github.com/zsh-users/zsh-syntax-highlighting/blob/master/highlighters/pattern/pattern-highlighter.zsh"
click node_regexp "https://github.com/zsh-users/zsh-syntax-highlighting/blob/master/highlighters/regexp/regexp-highlighter.zsh"
click node_root "https://github.com/zsh-users/zsh-syntax-highlighting/blob/master/highlighters/root/root-highlighter.zsh"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_zle,node_entry,node_user toneBlue
class node_main,node_brackets,node_cursor,node_line,node_pattern,node_regexp,node_root toneAmber
class node_terminal toneMint
```

## Components

### Zsh Integration

- **Zsh Line Editor**
- [ZLE Hook](https://github.com/zsh-users/zsh-syntax-highlighting/blob/master/zsh-syntax-highlighting.zsh): `zsh-syntax-highlighting.zsh`

### Highlighter Plugins

- [Main Highlighter](https://github.com/zsh-users/zsh-syntax-highlighting/blob/master/highlighters/main/main-highlighter.zsh): `highlighters/main/main-highlighter.zsh`
- [Bracket Highlighter](https://github.com/zsh-users/zsh-syntax-highlighting/blob/master/highlighters/brackets/brackets-highlighter.zsh): `highlighters/brackets/brackets-highlighter.zsh`
- [Cursor Highlighter](https://github.com/zsh-users/zsh-syntax-highlighting/blob/master/highlighters/cursor/cursor-highlighter.zsh): `highlighters/cursor/cursor-highlighter.zsh`
- [Line Highlighter](https://github.com/zsh-users/zsh-syntax-highlighting/blob/master/highlighters/line/line-highlighter.zsh): `highlighters/line/line-highlighter.zsh`
- [Pattern Highlighter](https://github.com/zsh-users/zsh-syntax-highlighting/blob/master/highlighters/pattern/pattern-highlighter.zsh): `highlighters/pattern/pattern-highlighter.zsh`
- [Regexp Highlighter](https://github.com/zsh-users/zsh-syntax-highlighting/blob/master/highlighters/regexp/regexp-highlighter.zsh): `highlighters/regexp/regexp-highlighter.zsh`
- [Root Highlighter](https://github.com/zsh-users/zsh-syntax-highlighting/blob/master/highlighters/root/root-highlighter.zsh): `highlighters/root/root-highlighter.zsh`

### Prompt Output

- **Interactive Terminal**

### Other components

- **Shell User**

## Connections

- Shell User → Zsh Line Editor: types command (evidence: `README.md`)
- Zsh Line Editor → ZLE Hook: runs hook (evidence: `README.md`)
- ZLE Hook → Main Highlighter: uses plugin
- ZLE Hook → Bracket Highlighter: uses plugin
- ZLE Hook → Cursor Highlighter: uses plugin
- ZLE Hook → Line Highlighter: uses plugin
- ZLE Hook → Pattern Highlighter: uses plugin
- ZLE Hook → Regexp Highlighter: uses plugin
- ZLE Hook → Root Highlighter: uses plugin
- ZLE Hook → Interactive Terminal: applies highlighting (evidence: `README.md`)
