folke / todo-comments.nvim

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

bug: Doesn't work #311

Closed hrqmonteiro closed 1 month ago

hrqmonteiro commented 2 months ago

Did you check docs and existing issues?

Neovim version (nvim -v)

NVIM v0.10.1

Operating system/version

openSUSE tumbleweed

Describe the bug

Doesn't work

image

image

Steps To Reproduce

Just try to use

local function _1_()
  local todo_comments = require("todo-comments")
  return todo_comments.setup({})
end
return {{"folke/todo-comments.nvim", dependencies = {"nvim-lua/plenary.nvim"}, config = _1_, opts = {signs = true}, lazy = false}}

--TODO

With the repro.lua:

image

Expected Behavior

To highlight it

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 = {} },
    -- add any other plugins here
  },
})
b0ae989c commented 2 months ago

This is not a bug. The default highlight pattern is .*<(KEYWORDS)\s*: as described in the docs. So // TODO will not be highlighted, but // TODO: text will be.

Should close.

hrqmonteiro commented 2 months ago

This is not a bug. The default highlight pattern is .*<(KEYWORDS)\s*: as described in the docs. So // TODO will not be highlighted, but // TODO: text will be.

Should close.

In case you didn't saw the video, i did that as well

Here it is this pattern in the repro.lua file:

image image

b0ae989c commented 2 months ago

There is no video in your post.

Could you make sure todo-comments.nvim setup func is actually called? You can check it by running :Lazy profile.

If that setup func is not called, you can add event = 'BufReadPost' to your config, or call :lua require('todo-comments').setup() directly.

b0ae989c commented 2 months ago

It is also possible some tasks in the testing framework are blocking the setup func, since it is deferred if it's called during startup. See https://github.com/folke/todo-comments.nvim/blob/8f45f353dc3649cb9b44cecda96827ea88128584/lua/todo-comments/config.lua#L90-L96

For the record, a repro without testing is totally fine. So I suspect this is some async issue in the testing framework.

Repro without testing:

local root = vim.fn.fnamemodify("./.repro", ":p")
for _, name in ipairs({ "config", "data", "state", "cache" }) do
    vim.env[("XDG_%s_HOME"):format(name:upper())] = root .. "/" .. name
end
local lazypath = root .. "/plugins/lazy.nvim"
if not vim.loop.fs_stat(lazypath) then
    vim.fn.system({ "git", "clone", "--filter=blob:none", "https://github.com/folke/lazy.nvim.git", lazypath })
end
vim.opt.runtimepath:prepend(lazypath)

local plugins = {
    "folke/tokyonight.nvim",
    { "folke/todo-comments.nvim", opts = {} },
    -- TODO: Fix
}
require("lazy").setup(plugins, {
    root = root .. "/plugins",
})
vim.cmd.colorscheme("tokyonight")

Screenshot: s

fhardison commented 1 month ago

Everything is working for me, but not the highlighting. I tried calling ":lua require('todo-comments').setup()", but didn't get any highlighting. is it possible it's an issue with iterm2 my terminal?

pencilcheck commented 1 month ago

Ah, it has to have colon for me, can it just match with TODO and a space in a comment as well?

-- TODO: wehiweh
-- TODO sdasd

Nvm, read through the readme again and found the config to change pattern

  highlight = {
    pattern = [[.*<(KEYWORDS)\s*:]], -- pattern or table of patterns, used for highlighting (vim regex)
  },