Skip to content

Commit 4566239

Browse files
Fix setting keyword faces for todo keyword with hyphen. Fixes #356
1 parent e915a50 commit 4566239

File tree

2 files changed

+27
-1
lines changed

2 files changed

+27
-1
lines changed

lua/orgmode/colors/highlights.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -187,7 +187,7 @@ function M.parse_todo_keyword_faces(do_syn_match)
187187
end
188188
end
189189
if not vim.tbl_isempty(hl_opts) then
190-
local hl_name = 'OrgKeywordFace' .. name
190+
local hl_name = 'OrgKeywordFace' .. name:gsub('%-', '')
191191
local hl = ''
192192
for hl_item, hl_values in pairs(hl_opts) do
193193
hl = hl .. ' ' .. hl_item .. '=' .. table.concat(hl_values, ',')

tests/plenary/colors/colors_spec.lua

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ describe('Colors', function()
5858
org_todo_keyword_faces = {
5959
NEXT = ':foreground "blue" :underline on :weight bold :background red :slant italic',
6060
CANCELED = ':foreground green :slant italic',
61+
['IN-PROGRESS'] = ':foreground red :weight bold',
6162
},
6263
})
6364

@@ -66,6 +67,7 @@ describe('Colors', function()
6667
assert.are.same({
6768
NEXT = 'OrgKeywordFaceNEXT',
6869
CANCELED = 'OrgKeywordFaceCANCELED',
70+
['IN-PROGRESS'] = 'OrgKeywordFaceINPROGRESS',
6971
}, result)
7072

7173
assert.are.same('red', get_color_opt('OrgKeywordFaceNEXT', 'bg', 'gui'))
@@ -90,9 +92,21 @@ describe('Colors', function()
9092
assert.are.same('', get_color_opt('OrgKeywordFaceCANCELED', 'underline', 'gui'))
9193
assert.are.same('', get_color_opt('OrgKeywordFaceCANCELED', 'underline', 'cterm'))
9294

95+
assert.are.same('', get_color_opt('OrgKeywordFaceINPROGRESS', 'bg', 'gui'))
96+
assert.are.same('', get_color_opt('OrgKeywordFaceINPROGRESS', 'bg', 'cterm'))
97+
assert.are.same('red', get_color_opt('OrgKeywordFaceINPROGRESS', 'fg', 'gui'))
98+
assert.are.same('', get_color_opt('OrgKeywordFaceINPROGRESS', 'fg', 'cterm'))
99+
assert.are.same('1', get_color_opt('OrgKeywordFaceINPROGRESS', 'bold', 'gui'))
100+
assert.are.same('', get_color_opt('OrgKeywordFaceINPROGRESS', 'bold', 'cterm'))
101+
assert.are.same('', get_color_opt('OrgKeywordFaceINPROGRESS', 'italic', 'gui'))
102+
assert.are.same('', get_color_opt('OrgKeywordFaceINPROGRESS', 'italic', 'cterm'))
103+
assert.are.same('', get_color_opt('OrgKeywordFaceINPROGRESS', 'underline', 'gui'))
104+
assert.are.same('', get_color_opt('OrgKeywordFaceINPROGRESS', 'underline', 'cterm'))
105+
93106
vim.cmd([[
94107
hi clear OrgKeywordFaceNEXT
95108
hi clear OrgKeywordFaceCANCELED
109+
hi clear OrgKeywordFaceINPROGRESS
96110
]])
97111

98112
vim.o.termguicolors = false
@@ -101,6 +115,7 @@ describe('Colors', function()
101115
assert.are.same({
102116
NEXT = 'OrgKeywordFaceNEXT',
103117
CANCELED = 'OrgKeywordFaceCANCELED',
118+
['IN-PROGRESS'] = 'OrgKeywordFaceINPROGRESS',
104119
}, result)
105120

106121
assert.are.same('9', get_color_opt('OrgKeywordFaceNEXT', 'bg', 'cterm'))
@@ -124,5 +139,16 @@ describe('Colors', function()
124139
assert.are.same('', get_color_opt('OrgKeywordFaceCANCELED', 'bold', 'cterm'))
125140
assert.are.same('', get_color_opt('OrgKeywordFaceCANCELED', 'underline', 'gui'))
126141
assert.are.same('', get_color_opt('OrgKeywordFaceCANCELED', 'underline', 'cterm'))
142+
143+
assert.are.same('', get_color_opt('OrgKeywordFaceINPROGRESS', 'bg', 'cterm'))
144+
assert.are.same('', get_color_opt('OrgKeywordFaceINPROGRESS', 'bg', 'gui'))
145+
assert.are.same('9', get_color_opt('OrgKeywordFaceINPROGRESS', 'fg', 'cterm'))
146+
assert.are.same('', get_color_opt('OrgKeywordFaceINPROGRESS', 'fg', 'gui'))
147+
assert.are.same('1', get_color_opt('OrgKeywordFaceINPROGRESS', 'bold', 'cterm'))
148+
assert.are.same('', get_color_opt('OrgKeywordFaceINPROGRESS', 'bold', 'gui'))
149+
assert.are.same('', get_color_opt('OrgKeywordFaceINPROGRESS', 'italic', 'cterm'))
150+
assert.are.same('', get_color_opt('OrgKeywordFaceINPROGRESS', 'italic', 'gui'))
151+
assert.are.same('', get_color_opt('OrgKeywordFaceINPROGRESS', 'underline', 'cterm'))
152+
assert.are.same('', get_color_opt('OrgKeywordFaceINPROGRESS', 'underline', 'gui'))
127153
end)
128154
end)

0 commit comments

Comments
 (0)