Skip to content

Commit

Permalink
feat(highlight): allow highlighting the full pattern (#180)
Browse files Browse the repository at this point in the history
this will allow highlighting `TODO(author):`

```lua
highlight = {
  pattern = [[(KEYWORDS)\s*(\([^\)]*\))?:]],
},
```


![image](https://user-images.githubusercontent.com/40219740/218302992-3ab3cd95-74c0-4313-9870-d2781238a42c.png)

fixes #10
fixes #179
  • Loading branch information
doongjohn authored Jul 6, 2024
1 parent 01b4599 commit ad775a7
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions lua/todo-comments/highlight.lua
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,10 @@ function M.match(str, patterns)
for _, pattern in pairs(patterns) do
local m = vim.fn.matchlist(str, [[\v\C]] .. pattern)
if #m > 1 and m[2] then
local kw = m[2]
local start = str:find(kw)
return start, start + #kw, kw
local matched = m[1]
local kw_only = m[2]
local start = str:find(matched, 1, true)
return start, start + #matched - 1, kw_only
end
end
end
Expand Down

0 comments on commit ad775a7

Please sign in to comment.