" Vim syntax highlighting for Klammertext (.kt and .k files). " The Vim counterpart of doc/edit/emacs/klammertext-mode.el's highlighting " and doc/edit/sublime/Klammertext.sublime-syntax. " " What it highlights (the same token classes as the other editors): " " Text removal (#): " # ... remove to end of line (marker + removed text) " ## ... remove to end of file (marker + removed text) " #[ ... ]# remove enclosed text, nestable (markers + removed) " #- #+ #/ whitespace operators: NOT removals, left unhighlighted " " Klammer applications (@), definitions (@@), system commands (@@@): " @name @@name @@@name opening (@ and name are one unit) " name@ name@@ name@@@ named closing " @ @@ @@@ bare closing " " Escapes: ^@ ^# ^| ^^ — the caret makes the next character literal; the " two characters are consumed as one (unhighlighted) unit, so the escaped " character is never read as a delimiter. A run of carets pairs " left-to-right, reproducing the language's parity rule. " " Literal klammers: @code ... code@ — the interior is verbatim (no # or @ " interpreted). SYNC: the literal-klammer set's source of truth is " LITERAL_KLAMMERS in doc/edit/shared/klammertext_edit.py; a static " syntax file cannot read it, so when you add a literal klammer 'foo', " copy the klammertextVerbatim region below with code -> foo (and mirror " it in the Emacs, Sublime, and VS Code artifacts; all are seeded with " just 'code'). " " How open vs. close is decided (the same rule as every other integration): " a delimiter whose NAME follows the @-run (@name) is an OPENING; a bare " @-run, or one whose NAME precedes it (name@), is a CLOSING. The " look-ahead \%(\w\|@\)\@! on every closing keeps 'foo@bar' correct: that @ " is followed by a name, so it opens @bar and 'foo' stays plain text. The " abbreviated @name-arg form colors only @name (the name ends at the first " hyphen), exactly like the other editors. " " Colors come from the shared Klammertext palette " (notes/klammertext_palette.md in the development tree): application blue, " definition green, system orange; each opening bright and its close the " same hue darker; full intensity on dark backgrounds, deepened (0.60x) on " light. All groups are `hi def`, so :highlight in your vimrc overrides. " Delimiter matching (jump + live highlight) is not a tokenizer concern — " it lives in the ftplugin/autoload files. if exists("b:current_syntax") finish endif " --- escapes: ^X makes X literal; consumed so # / @ are not delimiters ---- " (Defined first; it wins by the earlier-start rule, since the ^ precedes.) syn match klammertextEscape /\^./ " --- text removal (#) ----------------------------------------------------- " Order matters: at the same start position, the LAST defined item wins. syn match klammertextRemovedLine /#.*$/ contains=klammertextMarkerLine syn match klammertextMarkerLine /#/ contained " whitespace operators #- #+N #/N : not removals, left unhighlighted syn match klammertextWhitespaceOp "#[-+/]\d*" syn region klammertextRemovedBlock matchgroup=klammertextMarker start=/#\[/ end=/\]#/ contains=klammertextRemovedBlock syn region klammertextRemovedFile matchgroup=klammertextMarker start=/##/ end=/\%$/ " --- system / target commands @@@ ---------------------------------------- syn match klammertextSysOpen /@\@1