Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Feature Request]: highlight author in TODO(author): #10

Closed
elianiva opened this issue May 14, 2021 · 10 comments · Fixed by #180 or #255
Closed

[Feature Request]: highlight author in TODO(author): #10

elianiva opened this issue May 14, 2021 · 10 comments · Fixed by #180 or #255
Labels
enhancement New feature or request stale

Comments

@elianiva
Copy link

It's quite common for a TODO to have an author, I was using treesitter comment parser and it can highlight the author name inside the parentheses. Currently I use both to make this happen but it would be cool if this plugin can do that as well, thanks! :)

here's a reference:
image

@folke
Copy link
Owner

folke commented May 15, 2021

Sounds like a great idea. I'll add it to the list :)

@folke folke added the enhancement New feature or request label May 15, 2021
@goncalves-diogo
Copy link

Hi, i've looked in these problem because i really needed the feature and I've developed regex to get to a result similar to what you expect i think.

In this image you can see the result i got:
image

I got the previous result with the following property on setup:

require("todo-comments").setup {
    highlight = {
      before = "", -- "fg" or "bg" or empty
      keyword = "bg", -- "fg", "bg", "wide" or empty. (wide is the same as bg, but will also highlight surrounding characters)
      after = "fg", -- "fg" or "bg" or empty
      pattern = [[.*<(KEYWORDS)(\([^\)]*\))?:]],
      comments_only = true, -- uses treesitter to match keywords in comments only
      max_line_len = 400, -- ignore lines longer than this
      exclude = {}, -- list of file types to exclude highlighting
    },
    search = {
        command = "rg",
        args = {
            "--color=never",
            "--no-heading",
            "--with-filename",
            "--line-number",
            "--column",
        },
        pattern = [[\b(KEYWORDS)(\([^\)]*\))?:]],
    },
}

@knpwrs
Copy link

knpwrs commented Sep 16, 2021

I think there has been a change to the highlighting logic to swallow the :, or whatever character comes after the keyword, because this is what I see with the custom regex solution:

image

That text is:

TODO: foobar
TODO(kp): delete the below once ...

@Daniele122898
Copy link

Is there a less hacky and more supported way of doing this then without stuff being swallowed?

@dav1d-wright
Copy link

dav1d-wright commented Jan 4, 2023

bumping this feature request because I am also looking for a way to do this. If there is any way I can help, let me know 🙂

dirn added a commit to dirn/dotfiles that referenced this issue Apr 29, 2023
While I enjoyed writing my TODO plugin, it was never great. Fortunately
there's a better one out there. While it [doesn't yet support][support]
highlighting keywords with things like authors or ticket numbers, it
does pretty much everything else I'd want it to do.

[support]: folke/todo-comments.nvim#10
@Rukenshia
Copy link

just stumbled across this while trying to figure out how to achieve it - would love to see this be a feature out of the box

@GoNZooo
Copy link

GoNZooo commented Aug 6, 2023

I can confirm that this is fixed by #180

@alexmozaidze
Copy link

It'd be nice if #180 was merged into the master branch

@ynhhoJ
Copy link

ynhhoJ commented Sep 11, 2023

I have created a fork with the latest changes and added support for highlighting from #180 MR.

You can find it here: https://github.com/ynhhoJ/todo-comments.nvim

I will delete my fork once the main repository will merge these changes into the master branch.

Feel free to use!

Copy link
Contributor

github-actions bot commented Jul 6, 2024

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.

@github-actions github-actions bot added the stale label Jul 6, 2024
@folke folke closed this as completed in #180 Jul 6, 2024
@folke folke closed this as completed in ad775a7 Jul 6, 2024
folke pushed a commit that referenced this issue Jul 6, 2024
Highlight the first capture group pattern, if there is a second
(typically nested) capture group, use it for keyword matching.
Allows highlighting `TODO(foo)` using `.*<((KEYWORDS)%(\(.{-1,}\))?):`.

Closes #185, closes #10

This is similar to #180, however that PR's matching behaviour is not
backwards compatible with the default highlight pattern used. This PR
retains the behaviour that only the first capturing group is
highlighted.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request stale
Projects
None yet
10 participants