Skip to content

Commit 4647d20

Browse files
feature: Use tree-sitter @spell directive for spell check
1 parent d383f5c commit 4647d20

File tree

4 files changed

+13
-7
lines changed

4 files changed

+13
-7
lines changed

lua/orgmode/colors/todo_highlighter.lua

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,10 +44,13 @@ local function add_todo_keyword_highlights()
4444
end, todo_keywords.DONE),
4545
' '
4646
)
47-
table.insert(lines, string.format([[(item . (expr) @OrgTODO (#any-of? @OrgTODO %s))]], todo_type))
48-
table.insert(lines, string.format([[(item . (expr) @OrgDONE (#any-of? @OrgDONE %s))]], done_type))
47+
table.insert(lines, string.format([[(item . (expr) @OrgTODO @nospell (#any-of? @OrgTODO %s))]], todo_type))
48+
table.insert(lines, string.format([[(item . (expr) @OrgDONE @nospell (#any-of? @OrgDONE %s))]], done_type))
4949
for face_name, face_hl in pairs(faces) do
50-
table.insert(lines, string.format([[(item . (expr) @%s (#eq? @%s %s))]], face_hl, face_hl, face_name))
50+
table.insert(
51+
lines,
52+
string.format([[(item . (expr) @%s @nospell (#eq? @%s %s))]], face_hl, face_hl, face_name)
53+
)
5154
end
5255
for _, v in ipairs(lines) do
5356
table.insert(all_lines, v)

queries/org/highlights.scm

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,9 @@
88
(headline (stars) @stars (#eq? @stars "******")) @OrgTSHeadlineLevel6
99
(headline (stars) @stars (#eq? @stars "*******")) @OrgTSHeadlineLevel7
1010
(headline (stars) @stars (#eq? @stars "********")) @OrgTSHeadlineLevel8
11+
(headline (item) @spell)
12+
(list (listitem (paragraph) @spell))
13+
(body (paragraph) @spell)
1114
(bullet) @OrgTSBullet
1215
(checkbox) @OrgTSCheckbox
1316
(checkbox status: (expr "-") @OrgTSCheckboxHalfChecked)
@@ -24,6 +27,6 @@
2427
(drawer) @OrgTSDrawer
2528
(tag_list) @OrgTSTag
2629
(plan) @OrgTSPlan
27-
(comment) @OrgTSComment
30+
(comment) @OrgTSComment @spell
2831
(directive) @OrgTSDirective
2932
(ERROR) @LspDiagnosticsUnderlineError

syntax/org.vim

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,9 @@ if exists('b:current_syntax')
55
endif
66

77
lua require('orgmode.colors.highlights').define_highlights()
8-
lua require('orgmode.org.syntax').add_todo_keywords_to_spellgood()
98
let s:ts_highlight = luaeval('require("orgmode.config"):ts_highlights_enabled()')
109
if !s:ts_highlight
10+
lua require('orgmode.org.syntax').add_todo_keywords_to_spellgood()
1111
runtime syntax/org_legacy.vim
1212
endif
1313

@@ -48,8 +48,6 @@ syn match org_timestamp_inactive /\(\[%%(diary-float.\+\]\)/
4848
hi def link org_timestamp PreProc
4949
hi def link org_timestamp_inactive Comment
5050

51-
syntax spell toplevel
52-
5351
lua require("orgmode.org.syntax").load_code_blocks()
5452

5553
let s:highlight_latex = luaeval('require("orgmode.config").org_highlight_latex_and_related')

syntax/org_legacy.vim

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,4 +119,6 @@ hi def link org_subtask_percent String
119119
hi def link org_subtask_percent_100 Identifier
120120
hi def link org_subtask_number_all Identifier
121121

122+
syntax spell toplevel
123+
122124
" vi: ft=vim:tw=80:sw=4:ts=4:fdm=marker

0 commit comments

Comments
 (0)