Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ Todo comes with the following defaults:
-- * keyword: highlights of the keyword
-- * after: highlights after the keyword (todo text)
highlight = {
enable = true, -- enable highlighting
multiline = true, -- enable multine todo comments
multiline_pattern = "^.", -- lua pattern to match the next multiline from the start of the matched keyword
multiline_context = 10, -- extra lines that will be re-evaluated when changing a line
Expand Down
1 change: 1 addition & 0 deletions lua/todo-comments/config.lua
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ local defaults = {
-- * keyword: highlights of the keyword
-- * after: highlights after the keyword (todo text)
highlight = {
enable = true, -- enable highlighting
multiline = true, -- enable multine todo comments
multiline_pattern = "^.", -- lua pattern to match the next multiline from the start of the matched keyword
multiline_context = 10, -- extra lines that will be re-evaluated when changing a line
Expand Down
46 changes: 24 additions & 22 deletions lua/todo-comments/highlight.lua
Original file line number Diff line number Diff line change
Expand Up @@ -214,31 +214,33 @@ function M.highlight(buf, first, last, _event)

local hl = Config.options.highlight

if not is_multiline then
-- before highlights
if hl.before == "fg" then
add_highlight(buf, Config.ns, hl_fg, lnum, 0, start)
elseif hl.before == "bg" then
add_highlight(buf, Config.ns, hl_bg, lnum, 0, start)
end
if hl.enable then
if not is_multiline then
-- before highlights
if hl.before == "fg" then
add_highlight(buf, Config.ns, hl_fg, lnum, 0, start)
elseif hl.before == "bg" then
add_highlight(buf, Config.ns, hl_bg, lnum, 0, start)
end

-- tag highlights
if hl.keyword == "wide" or hl.keyword == "wide_bg" then
add_highlight(buf, Config.ns, hl_bg, lnum, math.max(start - 1, 0), finish + 1)
elseif hl.keyword == "wide_fg" then
add_highlight(buf, Config.ns, hl_fg, lnum, math.max(start - 1, 0), finish + 1)
elseif hl.keyword == "bg" then
add_highlight(buf, Config.ns, hl_bg, lnum, start, finish)
elseif hl.keyword == "fg" then
add_highlight(buf, Config.ns, hl_fg, lnum, start, finish)
-- tag highlights
if hl.keyword == "wide" or hl.keyword == "wide_bg" then
add_highlight(buf, Config.ns, hl_bg, lnum, math.max(start - 1, 0), finish + 1)
elseif hl.keyword == "wide_fg" then
add_highlight(buf, Config.ns, hl_fg, lnum, math.max(start - 1, 0), finish + 1)
elseif hl.keyword == "bg" then
add_highlight(buf, Config.ns, hl_bg, lnum, start, finish)
elseif hl.keyword == "fg" then
add_highlight(buf, Config.ns, hl_fg, lnum, start, finish)
end
end
end

-- after highlights
if hl.after == "fg" then
add_highlight(buf, Config.ns, hl_fg, lnum, finish, #line)
elseif hl.after == "bg" then
add_highlight(buf, Config.ns, hl_bg, lnum, finish, #line)
-- after highlights
if hl.after == "fg" then
add_highlight(buf, Config.ns, hl_fg, lnum, finish, #line)
elseif hl.after == "bg" then
add_highlight(buf, Config.ns, hl_bg, lnum, finish, #line)
end
end

if not is_multiline then
Expand Down