A lightweight and customizable Neovim plugin that highlights todo tags in comments.
- Customizable Todo Tags: Define your own todo keywords and highlight groups
- Smart Highlighting: Only highlights tags in comment regions
- Case Sensitivity: Control whether tags are case-sensitive
- Performance: Efficiently highlights only visible regions with throttling
- Exclusion Rules: Exclude specific filetypes and buftypes
- Priority Control: Set highlight priority to override other plugins
{
"fau818/todotag.nvim",
dependencies = "folke/todo-comments.nvim", -- Optional: enhances TODO management
opts = {},
}For a more complete lazy.nvim configuration with custom highlights, see the Comprehensive Configuration section.
The plugin starts automatically when Neovim launches, but you can control it with these commands:
:TodotagStart " Start highlighting todo tags
:TodotagStop " Stop highlighting todo tagsBy default, the plugin highlights the keyword TODO in comments with the Todo highlight group.
You can customize the plugin's behavior by passing a configuration table to setup():
require("todotag").setup({
-- Keywords recognized as todo tags
keywords = {
todo = { hl_group = "Todo", case_sensitive = false },
fix = { hl_group = "Error", case_sensitive = true },
note = { hl_group = "DiagnosticInfo", case_sensitive = false },
},
-- Highlight priority (default: 501, covers todo-comments.nvim)
priority = 501,
-- Throttle updates (in ms, default: 250)
throttle = 250,
-- Only highlight in visible area (default: true)
only_visible = true,
-- Exclude these filetypes
exclude_ft = { "help", "netrw", "tutor" },
-- Exclude these buftypes
exclude_bt = { "nofile", "prompt" },
})You can define your own highlight groups using Neovim's Lua API or Vimscript:
-- Define highlight groups with Lua API
vim.api.nvim_set_hl(0, "MyTodoTag", { fg = "#ffffff", bg = "#ff0000", bold = true })
vim.api.nvim_set_hl(0, "MyNoteTag", { fg = "#1a1a2e", bg = "#a6c1ee", italic = true })" Define highlight groups with Vimscript
hi MyTodoTag guifg=#ffffff guibg=#ff0000
hi MyNoteTag guifg=#1a1a2e guibg=#a6c1eeThen use your custom groups in the plugin configuration:
require("todotag").setup({
keywords = {
todo = { hl_group = "MyTodoTag", case_sensitive = false },
note = { hl_group = "MyNoteTag", case_sensitive = false },
},
})When case_sensitive is false, the plugin will match tags regardless of case:
TODO,Todo,todo, andtOdOwill all be matched
When case_sensitive is true, only the exact case will be matched.
The plugin detects if a tag is inside a comment using two methods:
- Treesitter (if available) for accurate comment detection
- Syntax highlighting fallback for legacy support
- Throttling: Updates are throttled to prevent performance issues
- Visible Area Only: Only highlights lines in the visible window
- Buffer Attach: Attaches only to valid buffers (excludes floats, help, etc.)
- State Management: Tracks valid lines to avoid unnecessary re-highlighting
-- Highlight bug tags with error group (case-insensitive)
require("todotag").setup({
keywords = {
bug = { hl_group = "Error", case_sensitive = false },
},
})Here's a focused example using lazy.nvim:
-- In your lazy.nvim plugin configuration
return {
"fau818/todotag.nvim",
dependencies = "folke/todo-comments.nvim", -- Optional dependency
opts = {
keywords = {
-- Primary TODO tag (green)
todo = { hl_group = "TodoTag", case_sensitive = false },
-- Information tag (blue)
note = { hl_group = "InfoTag", case_sensitive = false },
-- Fix tag (red)
fix = { hl_group = "FixTag", case_sensitive = false },
},
only_visible = true, -- Highlight only visible lines (performance)
throttle = 250, -- Throttle updates
},
config = function(_, opts)
-- Define custom highlight groups with literal colors
vim.api.nvim_set_hl(0, "TodoTag", { fg = "#39CC8F", bold = true, italic = true })
vim.api.nvim_set_hl(0, "InfoTag", { fg = "#7AA2F7", bold = true, italic = true })
vim.api.nvim_set_hl(0, "FixTag", { fg = "#C53B53", bold = true, italic = true })
require("todotag").setup(opts)
end,
}- Ensure the tag is inside a comment
- Check that the filetype is not excluded
- Verify the tag is not in a listed exclude buftype
- Make sure the plugin is started with
:TodotagStart
- Increase the
throttlevalue to reduce the frequency of updates - Set
only_visibletotrueto only highlight visible lines - Reduce the number of keywords if you have many custom tags
Contributions are welcome! Please feel free to submit issues and pull requests.
MIT License - see LICENSE file for details
If you have any questions or issues, please open an issue on the GitHub repository: issues
- Inspired by various todo highlighting plugins
- Uses ideas from folke/todo-comments.nvim

