todo-comments.lua 3.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. -- todo 标签
  2. return {
  3. "folke/todo-comments.nvim",
  4. dependencies = { "nvim-lua/plenary.nvim" },
  5. opts = {
  6. {
  7. signs = true, -- show icons in the signs column
  8. sign_priority = 8, -- sign priority
  9. -- keywords recognized as todo comments
  10. keywords = {
  11. FIX = {
  12. icon = " ", -- icon used for the sign, and in search results
  13. color = "error", -- can be a hex color, or a named color (see below)
  14. alt = { "FIXME", "BUG", "FIXIT", "ISSUE" }, -- a set of other keywords that all map to this FIX keywords
  15. -- signs = false, -- configure signs for some keywords individually
  16. },
  17. TODO = { icon = " ", color = "info" },
  18. HACK = { icon = " ", color = "warning" },
  19. WARN = { icon = " ", color = "warning", alt = { "WARNING", "XXX" } },
  20. PERF = { icon = " ", alt = { "OPTIM", "PERFORMANCE", "OPTIMIZE" } },
  21. NOTE = { icon = " ", color = "hint", alt = { "INFO" } },
  22. TEST = { icon = "⏲ ", color = "test", alt = { "TESTING", "PASSED", "FAILED" } },
  23. },
  24. gui_style = {
  25. fg = "NONE", -- The gui style to use for the fg highlight group.
  26. bg = "BOLD", -- The gui style to use for the bg highlight group.
  27. },
  28. merge_keywords = true, -- when true, custom keywords will be merged with the defaults
  29. -- highlighting of the line containing the todo comment
  30. -- * before: highlights before the keyword (typically comment characters)
  31. -- * keyword: highlights of the keyword
  32. -- * after: highlights after the keyword (todo text)
  33. highlight = {
  34. multiline = true, -- enable multine todo comments
  35. multiline_pattern = "^.", -- lua pattern to match the next multiline from the start of the matched keyword
  36. multiline_context = 10, -- extra lines that will be re-evaluated when changing a line
  37. before = "", -- "fg" or "bg" or empty
  38. 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)
  39. after = "fg", -- "fg" or "bg" or empty
  40. pattern = [[.*<(KEYWORDS)\s*:]], -- pattern or table of patterns, used for highlighting (vim regex)
  41. comments_only = true, -- uses treesitter to match keywords in comments only
  42. max_line_len = 400, -- ignore lines longer than this
  43. exclude = {}, -- list of file types to exclude highlighting
  44. },
  45. -- list of named colors where we try to extract the guifg from the
  46. -- list of highlight groups or use the hex color if hl not found as a fallback
  47. colors = {
  48. error = { "DiagnosticError", "ErrorMsg", "#DC2626" },
  49. warning = { "DiagnosticWarn", "WarningMsg", "#FBBF24" },
  50. info = { "DiagnosticInfo", "#2563EB" },
  51. hint = { "DiagnosticHint", "#10B981" },
  52. default = { "Identifier", "#7C3AED" },
  53. test = { "Identifier", "#FF00FF" }
  54. },
  55. search = {
  56. command = "rg",
  57. args = {
  58. "--color=never",
  59. "--no-heading",
  60. "--with-filename",
  61. "--line-number",
  62. "--column",
  63. },
  64. -- regex that will be used to match keywords.
  65. -- don't replace the (KEYWORDS) placeholder
  66. pattern = [[\b(KEYWORDS):]], -- ripgrep regex
  67. -- pattern = [[\b(KEYWORDS)\b]], -- match without the extra colon. You'll likely get false positives
  68. },
  69. }
  70. }
  71. }