Skip to content

Commit 12cce60

Browse files
ObserverOfTimeclason
authored andcommitted
feat: support modelines
1 parent 3320dbd commit 12cce60

File tree

6 files changed

+5054
-4840
lines changed

6 files changed

+5054
-4840
lines changed

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -50,11 +50,11 @@ Known issues
5050
- `column_heading` currently only recognizes tilde `~` preceded by space (i.e.
5151
`foo ~` not `foo~`). This covers 99% of :help files.
5252
- `column_heading` children should be plaintext, but currently are parsed as `$._atom`.
53+
- `modeline` must be preceded by a blank line.
5354

5455
TODO
5556
----
5657

57-
- `line_modeline` ?
5858
- `tag_heading` : line(s) containing only tags, typically implies a "heading"
5959
before a block.
6060

grammar.js

+4
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ module.exports = grammar({
2626
seq(
2727
repeat($._blank), // Eat blank lines at top of file.
2828
repeat($.block),
29+
repeat($.modeline),
2930
),
3031

3132
_atom: ($) => choice(
@@ -169,6 +170,9 @@ module.exports = grammar({
169170
choice($.codeblock, '\n')
170171
),
171172

173+
// Modeline: must start with "vim:" (optionally preceded by whitespace)
174+
modeline: ($) => token(prec(2, /[\t ]*vim:[^\n]+\n/)),
175+
172176
// "Column heading": plaintext followed by "~".
173177
// Intended for table column names per `:help help-writing`.
174178
// TODO: children should be $.word (plaintext), not $.atom.

queries/vimdoc/highlights.scm

+2
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,8 @@
4848

4949
(url) @string.special.url
5050

51+
(modeline) @keyword.directive
52+
5153
((note) @comment.hint
5254
(#any-of? @comment.hint "Note:" "NOTE:" "Notes:"))
5355

src/grammar.json

+18
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/node-types.json

+8
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)