folke / todo-comments.nvim

✅ Highlight, list and search todo comments in your projects
Apache License 2.0
3.24k stars 94 forks source link

feature: Allow multiple highlight colors (expand #255) #306

Open aarondill opened 3 months ago

aarondill commented 3 months ago

Did you check the docs?

Is your feature request related to a problem? Please describe.

I'd like to highlight the user portion of todo comments in a different color. For example, in the below, FIXME would be one color, (folke) would be a different, and : something is broken would remain unhighlighted.

--- FIXME(folke): something is broken

Describe the solution you'd like

Accept a list for the color argument. Color each capture group in the regex after the first with it's corresponding color. For example, the below would accomplish the above highlighting.

{
    keywords = {
      FIXME = {  color = {"error", "user"} }
    },
    colors = {
      error = { fg = "#ff0000" },
      user = { fg = "#ffa500" },
    },
    highlight = {
      pattern = [[.*<((KEYWORDS)\s*(.*)?\s*:)]],
      multiline = false,
      after = "",
      keyword = "bg",
    },
}

Describe alternatives you've considered

  1. reverting to the builtin comment.scm and tree-sitter-comment
  2. Leave it as is.

Additional context

No response

aarondill commented 3 months ago

This is similar to the desired result (this is tree-sitter-comment): 2024-08-02_17-34

Kyren223 commented 3 months ago

@aarondill Hey, I am looking for this exact feature, how did u achieve what's in your screenshot?

aarondill commented 3 months ago

@Kyren223, that screenshot is currently impossible to replicate with this plugin. If you want exactly that screenshot though, you can uninstall this plugin and install the typescript comment parser via :TSInstall comment

Kyren223 commented 3 months ago

@aarondill ah thx, I might end up forking this, I have wanted to have more customization for a while, like being able to specify both a bg and fg per section per type so I can have have 3 splits or even more for -- |TODO|(kyren)|: |text| (| used to indicate diff sections) EDIT: and then instead of color = it'd be color = { section = value1, section2 = value2 }

aarondill commented 3 months ago

if you do, please open a PR to hopefully upstream those changes to the rest of us 😃

github-actions[bot] commented 2 months ago

This issue is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 7 days.

aarondill commented 2 months ago

not stale.

aarondill commented 2 months ago

@Kyren223 did you get anywhere with that?

Kyren223 commented 2 months ago

Currently I mostly use IntelliJ + IdeaVim (as I code in java), and for what I do in NeoVim (docs for the Java project) I don't really need this feature, so I haven't needed it. I might pick it up if my next project will use something like Rust where nvim is good at.

github-actions[bot] commented 1 month ago

This issue is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 7 days.

aarondill commented 1 month ago

a comment a day keeps the stalebot away 😃