SynEdit Highlighter TextMate: what changed
Revision 0 to 1. Removed lines have a minus sign; added lines have a plus sign.
Title: SynEdit Highlighter TextMate
| Old | New | Line | |
|---|---|---|---|
| 1 | + | > **Note:** This page is about the TSynTextMateSyn Highlighter in SynEdit and in the IDE. | |
| 2 | + | ||
| 3 | + | > **Note:** Lazarus 3.99 and up only | |
| 4 | + | ||
| 5 | + | __toc__ | |
| 6 | + | ||
| 7 | + | # About | |
| 8 | + | ||
| 9 | + | SynEdit supports highlighting based on TextMate grammar (as also used by VSCode). | |
| 10 | + | ||
| 11 | + | # Supported Grammar | |
| 12 | + | ||
| 13 | + | The general documentation can be found with the TextMate project. | |
| 14 | + | ||
| 15 | + | ## Match | |
| 16 | + | ||
| 17 | + | Patterns defined using "Match" should fully work. | |
| 18 | + | ||
| 19 | + | ## Begin , End | |
| 20 | + | ||
| 21 | + | Patterns defined using "Begin" / "End" should fully work. | |
| 22 | + | ||
| 23 | + | ### applyEndPatternLast | |
| 24 | + | ||
| 25 | + | Should work. | |
| 26 | + | ||
| 27 | + | ### Back-references in "End" patterns | |
| 28 | + | ||
| 29 | + | According to the documentation those shall refer to capture groups in the "Begin" pattern. | |
| 30 | + | ||
| 31 | + | This feature has experimental support. | |
| 32 | + | ||
| 33 | + | ## ~~While~~ | |
| 34 | + | ||
| 35 | + | Patterns defined using "while" / "end" will be accepted, but may not work. The original project supplies no documentation about them (other than that they exist). | |
| 36 | + | ||
| 37 | + | ## Captures | |
| 38 | + | ||
| 39 | + | Should work. The original project supplies no documentation on resolving conflicts. There may be differences in behaviour. | |
| 40 | + | ||
| 41 | + | ## Regular expressions | |
| 42 | + | ||
| 43 | + | Are based on TRegExpr (as in the fpc distro, but updated). | |
| 44 | + | ||
| 45 | + | # Adapting an existing Grammar | |
| 46 | + | ||
| 47 | + | The below list is work in progress. Issue may/will be discovered/documented/fixed as the feature gets used. | |
| 48 | + | ||
| 49 | + | ## "sampleText": | |
| 50 | + | ||
| 51 | + | For the IDE color configurator: | |
| 52 | + | ||
| 53 | + | ` {`\ | |
| 54 | + | ` "sampleText": "dorem ipsum foo bar"`\ | |
| 55 | + | ` }` | |
| 56 | + | ||
| 57 | + | ## unsupported regex | |
| 58 | + | ||
| 59 | + | The HL will return errors for them. The IDE can display them in Tools \> Options: Editor \> Display \> Color \> TML Setup | |
| 60 | + | ||
| 61 | + | \- \[:alpha:\] style groups are not supported | |
| 62 | + | ||
| 63 | + | \- Unicode features are limited/unavailable (depends on support by TRegExpr, when compiled for non-widestring). | |
| 64 | + | ||
| 65 | + | ## Replacing "while" patterns | |
| 66 | + | ||
| 67 | + | As needed... | |
| 68 | + | ||
| 69 | + | ## Color names / Scopes | |
| 70 | + | ||
| 71 | + | The IDE will display a configuration for each individual scope. | |
| 72 | + | ||
| 73 | + | Unlike VSCode a color can not be defined for multiple scopes at once by matching them. It is therefore advisable to reduce the amount of scopes to whatever is really needed. | |
| 74 | + | ||
| 75 | + | Some grammar may have different scope names for opening/closing brackets (or quotes). This interferes with SynEdits logic, which insists that matchig brackets (for highlighting, when at caret) must have the same scope. Scopes for open/closing brackets/quotes/... should be changed to have the same name. | |
| 76 | + | ||
| 77 | + | # IDE | |
| 78 | + | ||
| 79 | + | To use a grammar file in the IDE copy it into the subfolder userschemes/tml in the primary-config-path. | |
| 80 | + | ||
| 81 | + | The IDE will list the files under Tools \> Options: Editor \> Display \> Color \> TML Setup - Part 1: files currently loaded and active. - Part 2: files currently in the folder. | |
| 82 | + | ||
| 83 | + | The active files (that can be chosen as HL) will only be loaded at IDE startup. | |
| 84 | + | ||
| 85 | + | The "Reload" button will reload the files in the folder, but **not** make them active. It will merely show if they could be parsed, or do have errors. Once errors are removed the IDE must be restarted to use them. | |
| 86 | + | ||
| 87 | + | --- | |
| 88 | + | *From the Free Pascal wiki, page "SynEdit Highlighter TextMate", as it stood on 2023-11-24 after a change by Alextpp, out of the wiki's dump of 2024-05-26. Copyright stays with the author who wrote it, according to the old wiki's [[Licensing]] page. If you have concerns about this material, [message the admin](/wiki-contact).* | |
| 89 | + | Category: SynEdit |
