Skip to content

Commit 78ea0a8

Browse files
Merge pull request #240 from gerritvreeman/fix-hi-queries
2 parents e1f3054 + a73d2c0 commit 78ea0a8

File tree

1 file changed

+47
-27
lines changed

1 file changed

+47
-27
lines changed

lua/orgmode/colors/todo_highlighter.lua

+47-27
Original file line numberDiff line numberDiff line change
@@ -13,35 +13,55 @@ local function add_todo_keyword_highlights()
1313
end
1414
local todo_keywords = config:get_todo_keywords()
1515
local faces = highlights.parse_todo_keyword_faces()
16-
utils.readfile(
17-
query_files[1],
18-
vim.schedule_wrap(function(err, lines)
19-
if err then
20-
return
21-
end
22-
local todo_type = table.concat(
23-
vim.tbl_map(function(word)
24-
return string.format('"%s"', word)
25-
end, todo_keywords.TODO),
26-
' '
16+
local all_lines = {}
17+
for i, _ in pairs(query_files) do
18+
if i ~= #query_files then
19+
utils.readfile(
20+
query_files[i],
21+
vim.schedule_wrap(function(err, lines)
22+
if err then
23+
return
24+
end
25+
for _, v in ipairs(lines) do
26+
table.insert(all_lines, v)
27+
end
28+
end)
2729
)
28-
local done_type = table.concat(
29-
vim.tbl_map(function(word)
30-
return string.format('"%s"', word)
31-
end, todo_keywords.DONE),
32-
' '
30+
else
31+
utils.readfile(
32+
query_files[i],
33+
vim.schedule_wrap(function(err, lines)
34+
if err then
35+
return
36+
end
37+
local todo_type = table.concat(
38+
vim.tbl_map(function(word)
39+
return string.format('"%s"', word)
40+
end, todo_keywords.TODO),
41+
' '
42+
)
43+
local done_type = table.concat(
44+
vim.tbl_map(function(word)
45+
return string.format('"%s"', word)
46+
end, todo_keywords.DONE),
47+
' '
48+
)
49+
table.insert(lines, string.format([[(item . (expr) @OrgTODO (#any-of? @OrgTODO %s))]], todo_type))
50+
table.insert(lines, string.format([[(item . (expr) @OrgDONE (#any-of? @OrgDONE %s))]], done_type))
51+
for face_name, face_hl in pairs(faces) do
52+
table.insert(lines, string.format([[(item . (expr) @%s (#eq? @%s %s))]], face_hl, face_hl, face_name))
53+
end
54+
for _, v in ipairs(lines) do
55+
table.insert(all_lines, v)
56+
end
57+
vim.treesitter.set_query('org', 'highlights', table.concat(all_lines, '\n'))
58+
if vim.bo.filetype == 'org' then
59+
vim.cmd([[filetype detect]])
60+
end
61+
end)
3362
)
34-
table.insert(lines, string.format([[(item . (expr) @OrgTODO (#any-of? @OrgTODO %s))]], todo_type))
35-
table.insert(lines, string.format([[(item . (expr) @OrgDONE (#any-of? @OrgDONE %s))]], done_type))
36-
for face_name, face_hl in pairs(faces) do
37-
table.insert(lines, string.format([[(item . (expr) @%s (#eq? @%s %s))]], face_hl, face_hl, face_name))
38-
end
39-
vim.treesitter.set_query('org', 'highlights', table.concat(lines, '\n'))
40-
if vim.bo.filetype == 'org' then
41-
vim.cmd([[filetype detect]])
42-
end
43-
end)
44-
)
63+
end
64+
end
4565
end
4666

4767
return {

0 commit comments

Comments
 (0)