folke / todo-comments.nvim

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

bug: Weird keyword highlighting without treesitter parser #323

Open Lun4m opened 1 week ago

Lun4m commented 1 week ago

Did you check docs and existing issues?

Neovim version (nvim -v)

0.10.0

Operating system/version

Ubuntu 22.04.1

Describe the bug

Probably related to #189, and I'm pretty sure the comment parser is not installed.

In a lua file: Screenshot from 2024-10-09 12-28-48

In a toml file: Screenshot from 2024-10-09 12-30-06

Of all the file types I commonly use only toml seems to have this problem. So maybe it's a treesitter issue?

Steps To Reproduce

  1. echo $'-- TODO: todo\n-- FIXME: fixme\n-- NOTE: note' > test.lua
  2. echo $'# TODO: todo\n# FIXME: fixme\n# NOTE: note' > test.toml
  3. nvim -u repro.lua test.lua → comments are greyed out for some reason
  4. :e test.toml → comments are colored, but the background of TODO and FIXME is highlighted.

If in step 3. you open test.toml instead, comments are greyed out and the background of TODO and FIXME is highlighted.

Expected Behavior

Keywords shouldn't have background highlighting.

Repro

vim.env.LAZY_STDPATH = ".repro"
load(vim.fn.system("curl -s https://raw.githubusercontent.com/folke/lazy.nvim/main/bootstrap.lua"))()

require("lazy.minit").repro({
  spec = {
    { 
      "folke/todo-comments.nvim",
      opts = { highlight = { keyword = "fg" } },
    },
  },
})
Lun4m commented 1 week ago

Ok, my bad, apparently it was indeed related to treesitter, installing the toml parser fixed it. I guess this is expected behavior since todo-comments gets the comment context from treesitter (by default comments_only = true), right?