SynEdit Highlighter TextMate: what changed
Revision 1 to 2. Removed lines have a minus sign; added lines have a plus sign.
| Old | New | Line | |
|---|---|---|---|
| 1 | 1 | > **Note:** This page is about the TSynTextMateSyn Highlighter in SynEdit and in the IDE. | |
| 2 | 2 | ||
| 3 | 3 | > **Note:** Lazarus 3.99 and up only | |
| 4 | 4 | ||
| 5 | 5 | __toc__ | |
| 6 | 6 | ||
| 7 | 7 | # About | |
| 8 | 8 | ||
| 9 | 9 | SynEdit supports highlighting based on TextMate grammar (as also used by VSCode). | |
| 10 | 10 | ||
| 11 | 11 | # Supported Grammar | |
| 12 | 12 | ||
| 13 | 13 | The general documentation can be found with the TextMate project. | |
| 14 | 14 | ||
| 15 | 15 | ## Match | |
| 16 | 16 | ||
| 17 | 17 | Patterns defined using "Match" should fully work. | |
| 18 | 18 | ||
| 19 | 19 | ## Begin , End | |
| 20 | 20 | ||
| 21 | 21 | Patterns defined using "Begin" / "End" should fully work. | |
| 22 | 22 | ||
| 23 | 23 | ### applyEndPatternLast | |
| 24 | 24 | ||
| 25 | 25 | Should work. | |
| 26 | 26 | ||
| 27 | 27 | ### Back-references in "End" patterns | |
| 28 | 28 | ||
| 29 | 29 | According to the documentation those shall refer to capture groups in the "Begin" pattern. | |
| 30 | 30 | ||
| 31 | 31 | This feature has experimental support. | |
| 32 | 32 | ||
| 33 | 33 | ## ~~While~~ | |
| 34 | 34 | ||
| 35 | 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 | 36 | ||
| 37 | 37 | ## Captures | |
| 38 | 38 | ||
| 39 | 39 | Should work. The original project supplies no documentation on resolving conflicts. There may be differences in behaviour. | |
| 40 | 40 | ||
| 41 | 41 | ## Regular expressions | |
| 42 | 42 | ||
| 43 | 43 | Are based on TRegExpr (as in the fpc distro, but updated). | |
| 44 | 44 | ||
| 45 | 45 | # Adapting an existing Grammar | |
| 46 | 46 | ||
| 47 | 47 | The below list is work in progress. Issue may/will be discovered/documented/fixed as the feature gets used. | |
| 48 | 48 | ||
| 49 | 49 | ## "sampleText": | |
| 50 | 50 | ||
| 51 | 51 | For the IDE color configurator: | |
| 52 | 52 | ||
| 53 | - | ||
| 54 | - | ||
| 55 | - | ||
| 53 | + | ```text | |
| 54 | + | { | |
| 55 | + | "sampleText": "dorem ipsum foo bar" | |
| 56 | + | } | |
| 57 | + | ``` | |
| 56 | 58 | ||
| 57 | 59 | ## unsupported regex | |
| 58 | 60 | ||
| 59 | 61 | The HL will return errors for them. The IDE can display them in Tools \> Options: Editor \> Display \> Color \> TML Setup | |
| 60 | 62 | ||
| 61 | 63 | \- \[:alpha:\] style groups are not supported | |
| 62 | 64 | ||
| 63 | 65 | \- Unicode features are limited/unavailable (depends on support by TRegExpr, when compiled for non-widestring). | |
| 64 | 66 | ||
| 65 | 67 | ## Replacing "while" patterns | |
| 66 | 68 | ||
| 67 | 69 | As needed... | |
| 68 | 70 | ||
| 69 | 71 | ## Color names / Scopes | |
| 70 | 72 | ||
| 71 | 73 | The IDE will display a configuration for each individual scope. | |
| 72 | 74 | ||
| 73 | 75 | 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 | 76 | ||
| 75 | 77 | 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 | 78 | ||
| 77 | 79 | # IDE | |
| 78 | 80 | ||
| 79 | 81 | To use a grammar file in the IDE copy it into the subfolder userschemes/tml in the primary-config-path. | |
| 80 | 82 | ||
| 81 | 83 | 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 | 84 | ||
| 83 | 85 | The active files (that can be chosen as HL) will only be loaded at IDE startup. | |
| 84 | 86 | ||
| 85 | 87 | 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 | 88 | ||
| 87 | 89 | --- | |
| 88 | 90 | *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 | 91 | Category: SynEdit |
