Skip to content

Commit 86080fb

Browse files
committed
doc: Explain mode-specific highlighting patterns
1 parent 092b597 commit 86080fb

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
# Changelog
22

33
## Unreleased
4+
- Used a different `hcl` grammar.
5+
- Added support for mode-specific highlighting patterns.
6+
- Added highlighting patterns for `terraform-mode`.
47

58
## 0.11.6 - 2022-03-28
69
- Updated `bash` grammar.

README.org

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ For each supported language, this package provides:
1919
** Highlighting Queries
2020
# *Note*: Highlighting styles are a mattter of taste.
2121

22-
Highlighting query patterns for a language are in the file ~queries/{lang}/highlights.scm~. Most of them are *intentionally different* from those from upstream repositories, which are more geared towards /GitHub's use cases/. We try to be more consistent with /Emacs's existing conventions/. (For some languages, this is WIP, so their patterns may look similar to upstream's.)
22+
Highlighting query patterns for a language are in the file ~queries/<lang>/highlights.scm~. Most of them are *intentionally different* from those from upstream repositories, which are more geared towards /GitHub's use cases/. We try to be more consistent with /Emacs's existing conventions/. (For some languages, this is WIP, so their patterns may look similar to upstream's.)
2323

2424
In general, try to follow what the docstrings of ~tree-sitter-hl-face:~ faces say. Most importantly:
2525
- Definitions and uses should be differentiated:
@@ -30,6 +30,9 @@ In general, try to follow what the docstrings of ~tree-sitter-hl-face:~ faces sa
3030
- Special faces should have high priority (placed earlier in the pattern list): ~@function.macro~, ~@type.builtin~, ~@variable.special~.
3131
- Patterns whose internals may be highlighted should have low priority (placed towards the end). Example: strings with interpolation.
3232

33+
*** Mode-specific highlighting
34+
Some languages are associated with multiple major modes. Mode-specific highlighting patterns are provided by the files ~queries/<lang>/highlights.<major-mode>.scm~. These are combined with the base highlighting patterns in ~queries/<lang>/highlights.scm~, but have higher precedence.
35+
3336
** Building Grammars from Source
3437
Note: If you also plan to work on [[https://github.com/emacs-tree-sitter/elisp-tree-sitter#building-grammars-from-source][elisp-tree-sitter]], it might be more convenient to work with this repository as a submodule.
3538

0 commit comments

Comments
 (0)