-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathtodocomments-config.lua
More file actions
71 lines (65 loc) · 2.88 KB
/
todocomments-config.lua
File metadata and controls
71 lines (65 loc) · 2.88 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
local M = {
'folke/todo-comments.nvim',
event = { 'BufReadPre', 'BufNewFile' }
}
M.opts = {
signs = false,
keywords = {
INFO = { icon = ' ', color = 'info' },
TODO = { icon = ' ', color = 'todo' },
HACK = { icon = ' ', color = 'hack' },
WARN = { icon = ' ', color = 'warn', alt = { 'WARNING' } },
NOTE = { icon = ' ', color = 'hint', alt = { 'HINT' } },
PERF = { icon = ' ', color = 'perf', alt = { 'OPTIMIZE' } },
FIX = { icon = ' ', color = 'error', alt = { 'ERROR', 'BUG', 'ISSUE' } },
},
merge_keywords = false, -- when true, custom keywords will be merged with the defaults
highlight = {
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
before = '',
keyword = 'wide_bg', -- 'fg', 'bg', 'wide', 'wide_bg', 'wide_fg' or empty. (wide and wide_bg is the same as bg, but will also highlight surrounding characters, wide_fg acts accordingly but with fg)
after = 'fg', -- 'fg' or 'bg' or empty
pattern = [[.*<(KEYWORDS)\s*:]], -- pattern or table of patterns, used for highlightng (vim regex)
comments_only = true, -- uses treesitter to match keywords in comments only
max_line_len = 200, -- ignore lines longer than this
exclude = {}, -- list of file types to exclude highlighting
},
colors = require('plugins.colorscheme.colorset').todocomments,
search = {
command = 'rg',
args = {
'--color=never',
'--no-heading',
'--with-filename',
'--line-number',
'--column',
},
pattern = [[\b(KEYWORDS):]], -- ripgrep regex
},
}
M.config = function(_, opts)
require('todo-comments').setup(opts)
-- HACK: force keyword highlight from wide_bg to bold fg style
for kw, options in pairs(opts.keywords) do
vim.api.nvim_set_hl(0, 'TodoBg' .. kw, { fg = opts.colors[options.color], bg = 'NONE', bold = true })
end
end
M.keys = function()
-- INFO: setup todocomments keymap
local todocomments_keymap = require('config.keymaps').todocomments
return {
{
todocomments_keymap.toggle,
function()
require('snacks').picker.todo_comments {
keywords = { 'INFO', 'TODO', 'WARN', 'NOTE', 'HACK', 'PERF', 'FIX' },
}
end
},
{ todocomments_keymap.next_todo, function() require('todo-comments').jump_next() end },
{ todocomments_keymap.prev_todo, function() require('todo-comments').jump_prev() end },
}
end
return M