From d94396b9de0f09f1ca8fac7114dd36f8036b81f8 Mon Sep 17 00:00:00 2001 From: Kyren223 Date: Thu, 4 Jul 2024 17:11:29 +0300 Subject: [PATCH] Neovim: filtered search todos, along with some other todo changes and trouble --- .config/nvim/lua/keymaps.lua | 1 + .config/nvim/lua/plugins/lsp-saga.lua | 1 - .config/nvim/lua/plugins/telescope.lua | 2 -- .config/nvim/lua/plugins/todo.lua | 25 ++++++++++++++++++------- 4 files changed, 19 insertions(+), 10 deletions(-) diff --git a/.config/nvim/lua/keymaps.lua b/.config/nvim/lua/keymaps.lua index 637ddd1..2b2dba8 100644 --- a/.config/nvim/lua/keymaps.lua +++ b/.config/nvim/lua/keymaps.lua @@ -3,6 +3,7 @@ vim.keymap.set({ 'n', 'i' }, '', 'ggVG', { desc = 'Visually Highlight vim.keymap.set('n', '', ':nohlsearch') vim.keymap.set('n', 'z', function() vim.cmd('Neotree close') + vim.cmd('Trouble todo close') end, { desc = '[Z]en Mode' }) -- Undo/Redo diff --git a/.config/nvim/lua/plugins/lsp-saga.lua b/.config/nvim/lua/plugins/lsp-saga.lua index 28480b2..35c0a3a 100644 --- a/.config/nvim/lua/plugins/lsp-saga.lua +++ b/.config/nvim/lua/plugins/lsp-saga.lua @@ -20,7 +20,6 @@ return { }, }) local diagnostic = require('lspsaga.diagnostic') - local unused = 5 vim.keymap.set('n', 'K', ':Lspsaga hover_doc', { desc = 'Display Docs' }) vim.keymap.set('n', 'R', ':Lspsaga rename', { desc = '[R]ename' }) diff --git a/.config/nvim/lua/plugins/telescope.lua b/.config/nvim/lua/plugins/telescope.lua index f62cce0..86a6cec 100644 --- a/.config/nvim/lua/plugins/telescope.lua +++ b/.config/nvim/lua/plugins/telescope.lua @@ -26,8 +26,6 @@ return { vim.keymap.set('n', 'ds', builtin.lsp_document_symbols, { desc = '[D]ocument [S]symbols' }) vim.keymap.set('n', 'ps', builtin.lsp_workspace_symbols, { desc = '[P]roject [S]ymbols' }) - -- TODO: Add filtering to TodoTelescope so it only shows "bad" things like TODOs, fixmes etc and not notes - vim.keymap.set('n', 'st', ':TodoTelescope', { desc = '[S]earch [T]odos' }) -- TODO: Look into the following -- builtin.git_commits diff --git a/.config/nvim/lua/plugins/todo.lua b/.config/nvim/lua/plugins/todo.lua index 553a20c..45b2877 100644 --- a/.config/nvim/lua/plugins/todo.lua +++ b/.config/nvim/lua/plugins/todo.lua @@ -1,19 +1,27 @@ return { 'folke/todo-comments.nvim', dependencies = { 'nvim-lua/plenary.nvim' }, + config = function() + require('todo-comments').setup() + vim.keymap.set('n', 'st', ':TodoTelescope keywords=TODO,FIX,WARN', { desc = '[S]earch [T]odos' }) + vim.keymap.set('n', 'lt', ':TodoTrouble', { desc = '[L]ist [T]odos' }) + end, opts = { - signs = false, -- show icons in the signs column + signs = true, -- show icons in the signs column sign_priority = 8, -- sign priority keywords = { + -- NOTE: These are "todos" + TODO = { icon = ' ', color = 'info', alt = { 'todo' } }, FIX = { icon = ' ', color = 'error', alt = { 'FIXME', 'BUG', 'ISSUE' } }, - TODO = { icon = ' ', color = 'info' }, - HACK = { icon = ' ', color = 'warning', alt = { 'SMELL', 'CODE SMELL', 'BAD', 'BAD PRACTICE' } }, WARN = { icon = ' ', color = 'warning', alt = { 'WARNING' } }, - PERF = { icon = ' ', color = 'performance', alt = { 'PERFORMANCE', 'OPTIMIZE' } }, + OPTIMIZE = { icon = ' ', color = 'performance' }, + -- NOTE: These are "notes" + PERF = { icon = ' ', color = 'performance', alt = { 'PERFORMANCE' } }, + HACK = { icon = ' ', color = 'warning', alt = { 'SMELL', 'CODE SMELL', 'BAD', 'BAD PRACTICE' } }, NOTE = { icon = ' ', color = 'hint', alt = { 'INFO' } }, TEST = { icon = '⏲ ', color = 'test', alt = { 'TESTING', 'PASSED', 'FAILED' } }, - --UNSAFE = { icon = "󰍛 ", color = "error", alt = { "SAFETY" } }, + UNSAFE = { icon = '󰍛 ', color = 'error', alt = { 'SAFETY' } }, }, gui_style = { @@ -34,8 +42,11 @@ return { before = '', -- "fg" or "bg" or empty keyword = 'wide', -- "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 highlighting (vim regex) - -- pattern = [[.*<(KEYWORDS)\s*]], -- pattern or table of patterns, used for highlighting (vim regex) + pattern = { + [[.*<(KEYWORDS)\s*:]], + -- [[.*<(KEYWORDS)\s*]], + -- [[.*<(KEYWORDS)\s*!()]], + }, -- pattern or table of patterns, used for highlighting (vim regex) comments_only = false, max_line_len = 400, exclude = {}, -- list of excluded filetypes