diff options
| author | Kyren223 <kyren223@proton.me> | 2025-08-02 19:58:59 +0300 |
|---|---|---|
| committer | Kyren223 <kyren223@proton.me> | 2025-08-02 19:58:59 +0300 |
| commit | c57e2e0d9b76da9502024f2e8d45c5d7707b3dfa (patch) | |
| tree | 9fec038e3a0faec21fef8838558f7dd7b516407c /.config/nvim/lua | |
| parent | 1f5d757474d8bb7b362364e46fc99f4a3685e143 (diff) | |
Fixed highlighting of multiple () in TODO lines, now only highlights the
first
Diffstat (limited to '.config/nvim/lua')
| -rw-r--r-- | .config/nvim/lua/autocmds.lua | 28 |
1 files changed, 13 insertions, 15 deletions
diff --git a/.config/nvim/lua/autocmds.lua b/.config/nvim/lua/autocmds.lua index ad8087b..f7440ef 100644 --- a/.config/nvim/lua/autocmds.lua +++ b/.config/nvim/lua/autocmds.lua @@ -214,28 +214,26 @@ function RenderTodoHighlights(bufnr) local lines = vim.api.nvim_buf_get_lines(bufnr, 0, -1, false) for i, line in ipairs(lines) do - -- 1) highlight keywords per group for _, cfg in pairs(groups) do for _, kw in ipairs(cfg.keywords) do for s, e in line:gmatch('()' .. kw .. '()') do + -- 1) highlight keyword vim.api.nvim_buf_add_highlight(bufnr, ns, cfg.hl, i - 1, s - 1, e - 1) - -- 2) highlight (...) parts only if a group keyword was found + -- 2) highlight (...) parts only if a keyword was found local start = 1 - while true do - local s, e = line:find('%b()', start) - if not s then - break - end - -- "(" and ")" - vim.api.nvim_buf_add_highlight(bufnr, ns, scopes.bracket, i - 1, s - 1, s) - vim.api.nvim_buf_add_highlight(bufnr, ns, scopes.bracket, i - 1, e - 1, e) - -- inner constant - if e - s > 1 then - vim.api.nvim_buf_add_highlight(bufnr, ns, scopes.constant, i - 1, s, e - 1) - end - start = e + 1 + local s, e = line:find('%b()', start) + if not s then + break end + -- "(" and ")" + vim.api.nvim_buf_add_highlight(bufnr, ns, scopes.bracket, i - 1, s - 1, s) + vim.api.nvim_buf_add_highlight(bufnr, ns, scopes.bracket, i - 1, e - 1, e) + -- inner constant + if e - s > 1 then + vim.api.nvim_buf_add_highlight(bufnr, ns, scopes.constant, i - 1, s, e - 1) + end + start = e + 1 -- 3) highlight any ":" as delimiter only if a group keyword was found for s, _ in line:gmatch('():') do |
