todo-comments.nvim
todo-comments.nvim copied to clipboard
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
It would be nice to be able to toggle highlighting as well 👁👁 Great work, thank you!
Good idea. I'll see what I can do!
I just pushed some changes:
- you can now simply run setup again with different options. the options override the options from previously calling setup
- you can also call
require("todo-comments").disable()to disable everything
so for @lcrockett:
-- disable signs
require("todo-comments").setup({signs = false})
-- enable signs again
require("todo-comments").setup({signs = true})
@edshamis
-- disable highlighting, but keep signs
require("todo-comments").setup({highlight = {before ="", keyword = "", after = ""}})
disable completely:
require("todo-comments").disable()
Thank you for the suggestion!
Tested -> this works great, excellent. In addition to this change, would it also be possible to allow enabling / disabling signs to be buffer bound ?
@lcrockett that's not possible right now.
What would be your use case for this?
I could add some options to exclude certain filetypes etc, but not sure if that's what you want
I personally use lots of splits within Neovim and additionally move to other adjacent TMUX panes. When doing so, I currently use autocommands (WinEnter, WinLeave, WinNew, BufEnter, etc..) to hide / unhide visualisations when switching buffers, like LSP indicators, git signs, listchars, indent markers, etc. and on top of it use vimade to fade all but the active Neovim split. This way i'm not distracted by other buffers in sight that are screaming for attention.
What i'm after is having the active buffer show todo signs, highlights, or both, if it's the active buffer. While still maintaining the possibility to keep todo visualisations in sight for out of focus buffers, just in case it is deemed helpful at that particular time, if that makes sense. Hence the buffer specific todo visualisation toggle request.
For an LSP indicator example of what i'm currently doing to hide / unhide visualisations, see https://github.com/neovim/neovim/issues/13324#issuecomment-847353681.