Coder Social home page Coder Social logo

todo-comments.nvim's Introduction

✅ Todo Comments

todo-comments is a lua plugin for Neovim >= 0.8.0 to highlight and search for todo comments like TODO, HACK, BUG in your code base.

image

✨ Features

  • highlight your todo comments in different styles
  • optionally only highlights todos in comments using TreeSitter
  • configurable signs
  • open todos in a quickfix list
  • open todos in Trouble
  • search todos with Telescope

⚡️ Requirements

📦 Installation

Install the plugin with your preferred package manager:

{
  "folke/todo-comments.nvim",
  dependencies = { "nvim-lua/plenary.nvim" },
  opts = {
    -- your configuration comes here
    -- or leave it empty to use the default settings
    -- refer to the configuration section below
  }
}

⚙️ Configuration

Todo comes with the following defaults:

{
  signs = true, -- show icons in the signs column
  sign_priority = 8, -- sign priority
  -- keywords recognized as todo comments
  keywords = {
    FIX = {
      icon = "", -- icon used for the sign, and in search results
      color = "error", -- can be a hex color, or a named color (see below)
      alt = { "FIXME", "BUG", "FIXIT", "ISSUE" }, -- a set of other keywords that all map to this FIX keywords
      -- signs = false, -- configure signs for some keywords individually
    },
    TODO = { icon = "", color = "info" },
    HACK = { icon = "", color = "warning" },
    WARN = { icon = "", color = "warning", alt = { "WARNING", "XXX" } },
    PERF = { icon = "", alt = { "OPTIM", "PERFORMANCE", "OPTIMIZE" } },
    NOTE = { icon = "", color = "hint", alt = { "INFO" } },
    TEST = { icon = "", color = "test", alt = { "TESTING", "PASSED", "FAILED" } },
  },
  gui_style = {
    fg = "NONE", -- The gui style to use for the fg highlight group.
    bg = "BOLD", -- The gui style to use for the bg highlight group.
  },
  merge_keywords = true, -- when true, custom keywords will be merged with the defaults
  -- highlighting of the line containing the todo comment
  -- * before: highlights before the keyword (typically comment characters)
  -- * keyword: highlights of the keyword
  -- * after: highlights after the keyword (todo text)
  highlight = {
    multiline = true, -- enable multine todo comments
    multiline_pattern = "^.", -- lua pattern to match the next multiline from the start of the matched keyword
    multiline_context = 10, -- extra lines that will be re-evaluated when changing a line
    before = "", -- "fg" or "bg" or empty
    keyword = "wide", -- "fg", "bg", "wide", "wide_bg", "wide_fg" or empty. (wide and wide_bg is the same as bg, but will also highlight surrounding characters, wide_fg acts accordingly but with fg)
    after = "fg", -- "fg" or "bg" or empty
    pattern = [[.*<(KEYWORDS)\s*:]], -- pattern or table of patterns, used for highlighting (vim regex)
    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
  },
  -- list of named colors where we try to extract the guifg from the
  -- list of highlight groups or use the hex color if hl not found as a fallback
  colors = {
    error = { "DiagnosticError", "ErrorMsg", "#DC2626" },
    warning = { "DiagnosticWarn", "WarningMsg", "#FBBF24" },
    info = { "DiagnosticInfo", "#2563EB" },
    hint = { "DiagnosticHint", "#10B981" },
    default = { "Identifier", "#7C3AED" },
    test = { "Identifier", "#FF00FF" }
  },
  search = {
    command = "rg",
    args = {
      "--color=never",
      "--no-heading",
      "--with-filename",
      "--line-number",
      "--column",
    },
    -- regex that will be used to match keywords.
    -- don't replace the (KEYWORDS) placeholder
    pattern = [[\b(KEYWORDS):]], -- ripgrep regex
    -- pattern = [[\b(KEYWORDS)\b]], -- match without the extra colon. You'll likely get false positives
  },
}

Jumping

Two methods are available to jump to the next/previous todo comment.

vim.keymap.set("n", "]t", function()
  require("todo-comments").jump_next()
end, { desc = "Next todo comment" })

vim.keymap.set("n", "[t", function()
  require("todo-comments").jump_prev()
end, { desc = "Previous todo comment" })

-- You can also specify a list of valid jump keywords

vim.keymap.set("n", "]t", function()
  require("todo-comments").jump_next({keywords = { "ERROR", "WARNING" }})
end, { desc = "Next error/warning todo comment" })

🚀 Usage

Todo matches on any text that starts with one of your defined keywords (or alt) followed by a colon:

  • TODO: do something
  • FIX: this should be fixed
  • HACK: weird code warning

Todos are highlighted in all regular files.

Each of the commands below accept the following arguments:

  • cwd - Specify the directory to search for comments, like:
:TodoTelescope cwd=~/projects/foobar
  • keywords - Comma separated list of keywords to filter results by. Keywords are case-sensitive.
:TodoTelescope keywords=TODO,FIX

🔎 :TodoQuickFix

This uses the quickfix list to show all todos in your project.

image

🔎 :TodoLocList

This uses the location list to show all todos in your project.

image

🚦 :Trouble todo

List all project todos in trouble

Use Trouble's filtering: Trouble todo filter = {tag = {TODO,FIX,FIXME}}

See screenshot at the top

🔭 :TodoTelescope

Search through all project todos with Telescope

image

todo-comments.nvim's People

Contributors

amarakon avatar andersondanilo avatar arpangreat avatar b0ae989c avatar canmetan avatar casdal avatar devonks avatar doongjohn avatar dpetka2001 avatar edman avatar folke avatar gaetanlepage avatar github-actions[bot] avatar gustavokatel avatar isak102 avatar knmac avatar kunzaatko avatar levitatingorange avatar liljaylj avatar lunarlambda avatar mcauley-penney avatar mike325 avatar ngpong avatar riddlew avatar rubyowo avatar yibuma avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

todo-comments.nvim's Issues

Changing default color for FIXME

I have successfully changed highlight color for all the other keywords but for the error keywords like FIX,FIXME and BUG , changing the default color doesn't reflect in the buffers. Is there anything I'm missing out on?

error scrolling in tsx file

For some reason this is only happening in tsx files for me. Issue goes away when I remove the plugin

Error detected while processing WinScrolled Autocommands for "*":
E5108: Error executing lua Vim:E866: (NFA regexp) Misplaced {

Highlight gone after formatting done by null-ls

I am evaluating replacing efm with jose-elias-alvarez/null-ls.nvim and have just discovered that with such autocmd autocmd BufWritePre <buffer> lua vim.lsp.buf.formatting_seq_sync() (tested stylua and eslint formatters configured in null-ls) highlights from TODO comments get cleared. That wasn't the case with efm.

Change position of label in telescope

Hey, love the plugin.

I have a feature request regarding telescope integration.

Would it be possible to change the position of the type (NOTE, FIX, TODO...) in the file list to the left side. For example in the screenshot below, some files are deeply nested and the kind can only be determined by the little icon on the side.

Ideally, comment type would be on the left so you always know what it is, instead of looking at the icon.

So: [icon] [type] [path]

Maybe even remove the content of the note (text after TODO, FIXME...) since it can be visible in the telescope preview and is cluttering the list.

image

Thanks for the amazing plugin!

Error executing vim.schedule lua callback

Hello,

I just tried using your plugin. This is my entire init.vim:

call plugin#begin()
Plug 'folke/todo-comments.nvim'
call plug#end()

and I tried this file (test.c):

// PERF
// HACK
// TODO
// NOTE
// FIX
// WARNING
int main() {
	return 0;
}

Only the TODO gets highlighted, and when I try to run :TodoQuickFix, I get

Error executing vim.schedule lua callback: .../plugged/todo-comments.nvim/lua/todo-comment
s/search.lua:67: attempt to index field 'fn' (a nil value)

Do you have any idea what I'm missing?

Thanks in advance

[Bug] error when typing last letter of a word(like TODO)

When i want to write the last letter of words used by this plugin like TODO, PERF, FIX etc etc...
So when i for example write the last O for TODO I get this weird error:
image

my todo-comments config:
return function()
    require("todo-comments").setup{
        signs = true, -- show icons in the signs column
        sign_priority = 1, -- sign priority
        -- keywords recognized as todo comments
        keywords = {
            FIX = {
                icon = "", -- icon used for the sign, and in search results
                color = "error", -- can be a hex color, or a named color (see below)
                alt = { "FIXME", "BUG", "FIXIT", "ISSUE" },
            },
            TODO = { icon = "", color = "info" },
            HACK = { icon = "", color = "warning" },
            WARN = { icon = "", color = "warning", alt = { "WARNING", "XXX" } },
            PERF = { icon = "", alt = { "OPTIM", "PERFORMANCE", "OPTIMIZE" } },
            NOTE = { icon = "", color = "hint", alt = { "INFO" } },
        },
        merge_keywords = true, -- when true, custom keywords will be merged with the defaults
        -- highlighting of the line containing the todo comment
        -- * before: highlights before the keyword (typically comment characters)
        -- * keyword: highlights of the keyword
        -- * after: highlights after the keyword (todo text)
        highlight = {
            before = "", -- "fg" or "bg" or empty
            keyword = "wide", -- "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)\s*]], -- pattern used for highlightng (vim regex)
            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
        },
        -- list of named colors where we try to extract the guifg from the
        -- list of hilight groups or use the hex color if hl not found as a fallback
        colors = {
            error = { "LspDiagnosticsDefaultError", "ErrorMsg", "#DC2626" },
            warning = { "LspDiagnosticsDefaultWarning", "WarningMsg", "#FBBF24" },
            info = { "LspDiagnosticsDefaultInformation", "#2563EB" },
            hint = { "LspDiagnosticsDefaultHint", "#10B981" },
            default = { "Identifier", "#7C3AED" },
        },
        search = {
            command = "rg",
            args = {
                "--color=never",
                "--no-heading",
                "--with-filename",
                "--line-number",
                "--column",
            },
            -- regex that will be used to match keywords.
            -- don't replace the (KEYWORDS) placeholder
            pattern = [[\b(KEYWORDS)\b]], -- ripgrep regex
            -- pattern = [[\b(KEYWORDS)\b]], -- match without the extra colon. You'll likely get false positives
        },
    }
end

Finds no TODO or FIXME (for me)

First of great Job!

i'm very certain this might be a issue with my setup.
so its included in my config like thIs:

packer.lua

    use {
        "folke/todo-comments.nvim",
        config = function()
            require("plugins.todo")
        end,
        cmd = {"TodoQuickFix", "TodoTrouble", "TodoTelescope"}
    }

plugins.todo

require("todo-comments").setup {
    signs = true, -- show icons in the signs column
    -- keywords recognized as todo comments
    keywords = {
        FIX = {
            icon = "", -- icon used for the sign, and in search results
            color = "error", -- can be a hex color, or a named color (see below)
            alt = {"FIXME", "BUG", "FIXIT", "FIX", "ISSUE"} -- a set of other keywords that all map to this FIX keywords
            -- signs = false, -- configure signs for some keywords individually
        },
        TODO = {icon = "", color = "info"},
        HACK = {icon = "", color = "warning"},
        WARN = {icon = "", color = "warning", alt = {"WARNING", "XXX"}},
        PERF = {icon = "", alt = {"OPTIM", "PERFORMANCE", "OPTIMIZE"}},
        NOTE = {icon = "", color = "hint", alt = {"INFO"}}
    },
    -- highlighting of the line containing the todo comment
    -- * before: highlights before the keyword (typically comment characters)
    -- * keyword: highlights of the keyword
    -- * after: highlights after the keyword (todo text)
    highlight = {
        before = "", -- "fg" or "bg" or empty
        keyword = "wide", -- "fg", "bg", "wide" or empty. (wide is the same as bg, but will also highlight surrounding characters)
        after = "fg" -- "fg" or "bg" or empty
    },
    -- list of named colors where we try to extract the guifg from the
    -- list of hilight groups or use the hex color if hl not found as a fallback
    colors = {
        error = {"LspDiagnosticsDefaultError", "ErrorMsg", "#DC2626"},
        warning = {"LspDiagnosticsDefaultWarning", "WarningMsg", "#FBBF24"},
        info = {"LspDiagnosticsDefaultInformation", "#2563EB"},
        hint = {"LspDiagnosticsDefaultHint", "#10B981"},
        default = {"Identifier", "#7C3AED"}
    }
}

Tested for LUA and RUST
i have multiple FIXME and TODO in src
but if i Trigger TodoTrouble, TodoTelescope, TodoQufickFix
it does not show me anything
neither Trouble has any content neither quickfix list is populated same for telescope

see attached video
Video

Can we use [?, !, * ] as keywords?

In vs code there is plugins that marks [?, !, * ] - symbols as [hack, warning, note].
I tried to put them in todo-comments keywords, but no luck. I also tried escaping with "\\!" but it still wont work. Any idea how to setup 'todo-comment' config keywords so they would work on code like below:

 #!   this is warning
 #?  will this work

Incompatible with phaazon/hop.nvim

Hey, nice plugin!

  • romgrk/nvim-treesitter-context: seems like floating window showing content gets hidden when cursor is on the line matched by todo-comments.nvim
  • phaazon/hop.nvim: when hop displays its extmarks all other highlighting is disabled, but background of todo-comments.nvim strings prevails

Looks super great though!

Bonus question - how does it side with comment parser from treesitter? Should it be uninstalled? Can they be used together?

Scrolling skips line

Actual behaviour:
When scrolling in the todo view using j/k, every keypress moves the cursor by 2 lines instead of 1.

Expected behaviour:
Scrolling with j/k moves the cursor down/up by a single line.

Windows 10, 20H2, Build 19042.1052
NVIM v0.5.0-dev+1414-g8cdffd42d
Build type: Release
LuaJIT 2.1.0-beta3

Must never exceed max results

E5108: Error executing lua .../start/telescope.nvim/lua/telescope/pickers/scroller.lua:66: Must never exceed max results: { result = 30, args = { 30 0 31 } }

How I Found This Error

I made a keybind using lua that calls :TodoTelescope<CR>. Then I call the keybind and the todo picker shows up with no results, and if I press the up or down arrow it gives me that error.

Scrolling in binary files results in error

When opening binary files I get this:

Error detected while processing WinScrolled Autocommands for "*":
E5108: Error executing lua Vim:E731: using Dictionary as a String

Using the master as of now.

Todo: ripgrep failed with exit code 1

I just installed this, running any of the commands yields

Todo: ripgrep failed with exit code 1

As well as that, none of the items like TODO etc. are highlighted.

I tried this with the following minimal config as well, which yields the same error

" ### Plugins ###
" TODO
call plug#begin('~/.vim/plugged')
Plug 'folke/todo-comments.nvim'
call plug#end()

" ### Configure todo-comments.nvim ###
lua << EOF
require('todo-comments').setup{}
EOF

I am running Ubuntu 20.04.2 LTS, using

ripgrep 11.0.2
-SIMD -AVX (compiled)
+SIMD +AVX (runtime)

and

NVIM v0.5.0-dev+1318-g61aefaf29
Build type: Release
LuaJIT 2.1.0-beta3

Customization of sign column separately

As far as I am aware, and apologies if I'm wrong, but you can't set the sign column foreground/background separately from the rest of the groups.

image

Note above how the background for the sign column isn't matched which makes sense based on the highlight groups I've defined, but my Normal and SignColumn have different background colors for both. The current set of highlight groups ended up looking like:

image

along with a configuration that looks like:

signs = true,
keywords = {
    FIX = {
        icon = ' ',
        color = 'error',
        alt = { 'FIXME', 'BUG', 'FIXIT', 'FIX', 'ISSUE' },
    },
    TODO = {
        icon = ' ',
        color = 'info',
    },
    HACK = {
        icon = ' ',
        color = 'warning',
    },
    WARN = {
        icon = ' ',
        color = 'warning',
        alt = { 'WARNING', 'XXX' },
    },
    PERF = {
        icon = ' ',
        color = 'warning',
        alt = { 'OPTIM', 'PERFORMANCE', 'OPTIMIZE' },
    },
    NOTE = {
        icon = ' ',
        color = 'hint',
        alt = { 'INFO', 'HINT' },
    },
},
highlight = {
    before = '',
    keyword = 'wide',
    after = 'fg',
},
colors = {
    error = { 'TodoCommentError' },
    warning = { 'TodoCommentWarning' },
    info = { 'TodoCommentInfo' },
    hint = { 'TodoCommentHint' },
    default = { 'TodoCommentDefault' },
},
pattern = '(KEYWORDS):',

Plugin is not working

Hi, sorry for the bad title but not sure how to put it.

I'm using OS X 11.4 Big sur with iterm 2 and a patched font
I cannot get the plugin to work, it doesn't highlight and it doesn't show todos in trouble or telescope

Note: When I say todos I mean everything, hack, perf...

imagen

I have even created a branch on my config disabling every plugin that's not todo-comments

I'm using NVIM v0.5.0-dev+7da86f55a

 - INFO: key_backspace (kbs) terminfo entry: key_backspace=^H
 - INFO: key_dc (kdch1) terminfo entry: key_dc=\E[3~
 - INFO: $TERM_PROGRAM='iTerm.app'
 - INFO: $COLORTERM='truecolor'

[ Feature Request ] A custom Tag for // TEST:

Sometimes we developers write a specific block of code to test the rest of it correct or Not.

So , I request you to please do so add a TAG for TEST:

It will be really helpfull 😄😄

Love this plugin ❤️❤️

Error when deleting a comment treesitter/query.lua:398: invalid end

It's not an important error but it's one.

When I delete with dd a todo comment and then hit u to undo I get a treesitter lua error on the statusline

Error executing lua callback: ...-62d67de/share/nvim/runtime/lua/vim/treesitter/query.lua:398: invalid end

Every plugin on my config is up to date and I'm using the latest version of nvim installed through homebrew

This bug sometimes causes the comment not to be highlighted with the plugin and/or not to have every char displayed (some times I get PER within an invisible F

Grabacion.de.pantalla.2021-07-10.a.las.17.19.14.mov

lazy loading not working

Hi @folke

Sorry to bother you for help. I am unsure why I can't get this plugin to load and I'm confused why as your other plugins works out of the box :/

the error message is that todo-comments isn't loaded. did you run setup()

my config

        use {
            "folke/todo-comments.nvim",
            requires = "nvim-lua/plenary.nvim",
            config = function()
                require("todo-comments").setup {
                -- your configuration comes here
                -- or leave it empty to use the default settings
                -- refer to the configuration section below
                }
            end
        }

I read the previous issues and entered the following command

:lua print(vim.inspect(require("todo-comments.config")))

The output ( I see its not loaded but I don't know why packer doesn't load)

{
  _setup = <function 1>,
  colors = <function 2>,
  keywords = {},
  loaded = false,
  ns = 1,
  options = {},
  setup = <function 3>,
  signs = <function 4>
}

I am sure the answer is silly, but I legit can't find it :(

Thanks man

[Feature Request] Multi Line Comment Highlight

Hey, awesome plugin, I really like it, but I find myself writing a lot of multi line comments.
Currently, they are highlighted like this:
image
This really bothers me and It would be cool to extend the highlighting of comments to the next line, if the Indentation of the first character aligns/matches.

Bug: Attempt to concatenate field `rg_regex` (a nil value)

Hey folke firstly thanks for this amazing plugin!

Whenever I do :TodoQuickFix or any other command of this plugin, I get stuck on this error. Not sure if it is a problem on my end or a bug with the plugin, but yeah I need some help with this.

Bug

Screenshot from 2021-05-14 17-18-09

Config

Screenshot from 2021-05-14 17-21-19

I am using the same config that you showed in the README.md as an example.

[Feature Request]: highlight author in `TODO(author):`

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

Something weird is going on? todo-comments is activating nvim-tree?

So, I have just added the Plug line, and a keymap:

nnoremap <silent><C-t> <cmd>TodoTelescope<CR>

Now, whenever I do "C-t", I do get TodoTelescope. However, while telescope is opened, do C-t again and for some reason, nvimtree (sidebar) is activated. Now, do "C-t" again and telescope dissapears, but sidebar remains. Weird thing comes now: do ":q" over and over and it won't quit, it will just close and re-open the file. Yep, ":q" re-opens the file.

How should I go about debugging this?

settings merging

Thank you for the plugin. Really nice to have such nice highlights in the code.

At the moment if I want to define a new color or keyword I need to define all of them since defaults are gone. For instance, I want to have a separate color for PERF:

require("todo-comments").setup {                                                     
  keywords = {                                                                       
    PERF = {icon = " ", color = "perf", alt = {"OPTIM", "PERFORMANCE", "OPTIMIZE"}},
  },                                                                                 
  colors = {                                                                         
    perf = {"Number", "#10B981"},                                                    
  }                                                                                  
}                                                                                    

Result is:
image

So I need to redefine all of them to have them colored:

require("todo-comments").setup {                                                     
  sings = false,                                                                     
  keywords = {                                                                       
    FIX = {                                                                          
      icon = " ",                                                                   
      color = "error",                                                               
      alt = {"FIXME", "BUG", "FIXIT", "FIX", "ISSUE"},                               
      -- signs = false, -- configure signs for some keywords individually            
    },                                                                               
    TODO = {icon = " ", color = "info"},                                            
    HACK = {icon = " ", color = "warning"},                                         
    WARN = {icon = " ", color = "warning", alt = {"WARNING"}},                      
    PERF = {icon = " ", color = "perf", alt = {"OPTIM", "PERFORMANCE", "OPTIMIZE"}},
    NOTE = {icon = " ", color = "hint", alt = {"INFO"}}                             
  },                                                                                 
  colors = {                                                                         
    perf = {"Number", "#10B981"},                                                    
    error = {"LspDiagnosticsDefaultError", "ErrorMsg", "#DC2626"},                   
    warning = {"LspDiagnosticsDefaultWarning", "WarningMsg", "#FBBF24"},             
    info = {"LspDiagnosticsDefaultInformation", "#2563EB"},                          
    hint = {"LspDiagnosticsDefaultHint", "#10B981"},                                 
    default = {"Identifier", "#7C3AED"}                                              
  }                                                                                  
}                                                                                    

Would be great if defaults remain the same if not redefined explicitly.

P.S. Also signs = false do not turn off the signs. Only individual setting per keyword do.

:TodoTelescope and :TodoTrouble don't respect .gitignore

First of all, this plugin is AWESOME! thanks for your work!

I noticed that when using :TodoTelescope or :TodoTrouble I get results from all files, including the ones specified in .gitignore. I couldn't find a way to configure this, but I believe the expected behavior should be to respect .gitignore by default (like the commands provided by telescope).

Keywords overridden by vim.tbl_deep_extend

Passing in something like just TODO as a key to keywords gets overridden with the entire set of defaults due to the call to vim.tbl_deep_extend in config.lua. It looks like there is some commented-out code to handle this, but I'm curious whether this is intended or not?

For example, my configuration specifies:

keywords = {
    FIX = {
        icon = ' ',
        color = 'error',
        alt = { 'FIXME', 'FIXIT', 'FIX', 'ISSUE' },
    },
    TODO = {
        icon = ' ',
        color = 'info',
    },
    NOTE = {
        icon = ' ',
        color = 'hint',
        alt = { 'HINT' },
    },
},

but if I add a line like:

print('DBGSTR => before=' .. vim.inspect(M.options))
M.options = vim.tbl_deep_extend("force", {}, defaults, M.options or {}, M._options or {})
print('DBGSTR => after=' .. vim.inspect(M.options))

I get:

DBGSTR => before={}
DBGSTR => after={
  ...
  keywords = {
    FIX = {
      alt = { "FIXME", "FIXIT", "FIX", "ISSUE" },
      color = "error",
      icon = " ",
      <metatable> = <table 1>
    },
    HACK = {
      color = "warning",
      icon = " ",
      <metatable> = <table 1>
    },
    NOTE = {
      alt = { "HINT" },
      color = "hint",
      icon = " ",
      <metatable> = <table 1>
    },
    PERF = {
      alt = { "OPTIM", "PERFORMANCE", "OPTIMIZE" },
      icon = " ",
      <metatable> = <table 1>
    },
    TODO = {
      color = "info",
      icon = " ",
      <metatable> = <table 1>
    },
    WARN = {
      alt = { "WARNING", "XXX" },
      color = "warning",
      icon = " ",
      <metatable> = <table 1>
    },
    <metatable> = <table 1>
  },
  ...
}

When I should get the same output as what was noted as input.

Bug: Error while calling lua chunk

Hello,

thanks you for this great plugin, I was searching for such thing for some time now.

Anyway, I wasn't able to initialize it properly. When I added the installation part to the nvim config, I was able to install it via PLUG manager:

        Plug 'nvim-lua/plenary.nvim'
        Plug 'folke/todo-comments.nvim'

        lua <<EOF
          require("todo-comments").setup {
            -- your configuration comes here
            -- or leave it empty to use the default settings
            -- refer to the configuration section below
          }
EOF

But, when I ran the neovim, I received this error:

Error detected while processing /Users/mcibulka/.config/nvim/init.vim:
line  423:
E5108: Error executing lua [string ":lua"]:1: module 'todo-comments' not found:
        no field package.preload['todo-comments']
        no file './todo-comments.lua'
        no file '/Users/runner/work/neovim/neovim/.deps/usr/share/luajit-2.1.0-beta3/todo-comments.lua'
        no file '/usr/local/share/lua/5.1/todo-comments.lua'
        no file '/usr/local/share/lua/5.1/todo-comments/init.lua'
        no file '/Users/runner/work/neovim/neovim/.deps/usr/share/lua/5.1/todo-comments.lua'
        no file '/Users/runner/work/neovim/neovim/.deps/usr/share/lua/5.1/todo-comments/init.lua'
        no file './todo-comments.so'
        no file '/usr/local/lib/lua/5.1/todo-comments.so'
        no file '/Users/runner/work/neovim/neovim/.deps/usr/lib/lua/5.1/todo-comments.so'
        no file '/usr/local/lib/lua/5.1/loadall.so'
Press ENTER or type command to continue

The TODO plugin didn't work. But when I reload the nvim config, it didn't gave me any error and the this plugin worked fine.

Here is the output of nvim --version:

❯ nvim --version
NVIM v0.5.0-dev+1321-gc57a85d53
Build type: Release
LuaJIT 2.1.0-beta3
Compilation: /Applications/Xcode_12.4.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/cc -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=1 -O2 -DNDEBUG -Wall -Wextra -pedantic -Wno-unused-parameter -Wstrict-prototypes -std=gnu99 -Wshadow -Wconversion -Wmissing-prototypes -Wimplicit-fallthrough -Wvla -fstack-protector-strong -fno-common -fdiagnostics-color=always -DINCLUDE_GENERATED_DECLARATIONS -D_GNU_SOURCE -DNVIM_MSGPACK_HAS_FLOAT32 -DNVIM_UNIBI_HAS_VAR_FROM -DMIN_LOG_LEVEL=3 -I/Users/runner/work/neovim/neovim/build/config -I/Users/runner/work/neovim/neovim/src -I/Users/runner/work/neovim/neovim/.deps/usr/include -I/Applications/Xcode_12.4.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX11.1.sdk/usr/include -I/Library/Frameworks/Mono.framework/Headers -I/Users/runner/work/neovim/neovim/build/src/nvim/auto -I/Users/runner/work/neovim/neovim/build/include
Compiled by [email protected]

Features: +acl +iconv +tui
See ":help feature-compile"

   system vimrc file: "$VIM/sysinit.vim"
  fall-back for $VIM: "/share/nvim"

Run :checkhealth for more info

Could somebody look at this error please?

Thank you

Intereference with lewis6991/gitsigns.nvim

Adding NOTE, TODO, FIXME etc hides the green markings that show where parts were added that usually show up with gitsigns.

What is the recommended way to toggle signs = true, -- show icons in the signs column as workaround?

Disable for specific filetypes

Hi @folke,

Been giving this plugin a try and enjoying it 👍🏾, I just started also testing out https://github.com/kristijanhusak/orgmode.nvim which includes syntax highlighting for org mode files which use todos for its own purposes/has its own syntax. In this case, I'd rather have that plugin handle things how it wants to rather than have this plugin enabled. Is there a way I can disable the plugin for certain filetypes.

Command TodoTrouble not working

command :TodoTrouble causes nvim to freeze, I can't do anything and the only way I could find out to get out of it is to close the terminal.

use {
  "folke/todo-comments.nvim",
  config = function()
    require("todo-comments").setup {}
  end
}
u.keymap("n", "<leader>gt", "TodoTelescope", ntst)

This is my config for todo-comments.
I am using latest nvim commit.
and I am on arch linux.

issue launching with vimscript init

Awesome plugin! Appreciate it.

I'm giving it a try, but having an issue using vim Plug with a vimscript init file.

If I place the recommended / default lua snippet you've provided to call setup in my init.vim I get the following error.

Error detected while processing VimEnter Autocommands for "*":  
E5108: Error executing lua .../plugged/todo-comments.nvim/lua/todo-comments/config.lua:123: attempt to concatenate local 'fg' (a nil value)

I expected the defaults to apply, etc.
any ideas?

Handle highlight groups priority

Hi, first of all thanks for the awesome plugin!
I'd like to have the whole higroup set to background ... It works pretty fine by itself.

highlight = {
  before = "bg",
  keyword = "wide",
  after = "bg",
},

immagine

I also setup gitsigns as following.

...
gitsigns.setup({
  signs = {
    add          = { text = '┃', hl = 'GitSignsAdd'   , numhl='GitSignsAddNr'   , linehl='GitSignsAddLn',  },
    change       = { text = '█', hl = 'GitSignsAdd'	  , numhl='GitSignsChangeNr', linehl='GitSignsChangeLn'},
    delete       = { text = '┃', hl = 'GitSignsDelete', numhl='GitSignsDeleteNr', linehl='GitSignsDeleteLn'},
    topdelete    = { text = '█', hl = 'GitSignsDelete', numhl='GitSignsDeleteNr', linehl='GitSignsDeleteLn'},
    changedelete = { text = '█', hl = 'GitSignsChange', numhl='GitSignsChangeNr', linehl='GitSignsChangeLn'},
  },
  linehl = true,
...
}

Let's say all the higroups above (GitSignsAdd, Delete, Change) define a guibg color (I also provide an example for the sake of it
highlight GitSignsAddLn none guibg=#222222"). gitsigns higlight groups seem to have the better of todocomments ones.
immagine

Of course one solution could rearrange the highlight group of todocomments to foreground only (or to disable linehl in gitsigns)

highlight = {
  before = "fg",
  keyword = "fg",
  after = "fg",
},

immagine

Is there a better way?
Thanks!

Highlighting not working in terminal

Hey,

it's me again. After updating to 0.5.0, the plugin is working for me.
I only have one issue: todo comments are not highlighted at all in terminal vim:
image
(top is terminal nvim, bottom is gnvim).

Any idea what's happening here? Thanks in advance.

Highlights in Telescope preview not correct

Absolutely love this plugin. Thanks!

The only problem I'm having is that the highlights are off in the Telescope preview (see screenshot):

Screen Shot 2021-06-24 at 14 49 54

Very possible I've overwritten them somehow, but I don't know what they might be. Any ideas?

neovim hangs when opening a minimized file

Opening a certain file in a project of mine with this plugin enabled makes neovim hang and I have to press Ctrl+c a couple of times in order to make things resume.

The original file before it was minimized runs just fine and I haven't run into this before trying to open this very specific file which I have attached (gzipped): redacted

Minimal config to reproduce using a freshly built neovim:

call plug#begin('~/.config/nvim/plugins')
  Plug 'folke/todo-comments.nvim'
call plug#end()

lua <<eof
require'todo-comments'.setup{}
eof

Alt for TODO has not effect

Can someone confirm that

TODO = { icon = "", color = "info", alt = {"TODO", "WIP","DONE"} },

Alt property - does not works - it wont highlight - additional keywords ...
image

Todo highlight don't show in zig

Todo don't show highlight in zig, but treesitter said it's TSComments
image

It show in :TodoTelescope
TodoTelescope

Typescript is working as normal
image

Please help me, I don't know what caused the problem

Signs display toggle

I was wondering if it was possible to be able to toggle the display signs on the fly, without having to change the configuration and restart Neovim. There were no indicators in the README or source that this functionality currently exists. I opportunistically (poorly) tried accomplishing this by changing lua/todo-comments/highlight.lua (see snippet below). This sort of works, however after setting the global variable todo_comments_disable_signs to true the signs only disappear after switching back and fourth with another buffer (redrawing issue ?).

Is it currently possible to toggle displaying signs on the fly ? If not, is that a feature request to make ? 👀

--- a/lua/todo-comments/highlight.lua
+++ b/lua/todo-comments/highlight.lua
@@ -126,12 +126,14 @@ function M.highlight(buf, first, last)
       end

       -- signs
-      local show_sign = Config.options.signs
-      if opts.signs ~= nil then
-        show_sign = opts.signs
-      end
-      if show_sign then
-        vim.fn.sign_place(0, "todo-signs", "todo-sign-" .. kw, buf, { lnum = lnum + 1, priority = 8 })
+      if not vim.g.todo_comments_disable_signs then
+        local show_sign = Config.options.signs
+        if opts.signs ~= nil then
+          show_sign = opts.signs
+        end
+        if show_sign then
+          vim.fn.sign_place(0, "todo-signs", "todo-sign-" .. kw, buf, { lnum = lnum + 1, priority = 8 })
+        end
       end
     end
   end

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.