This plugin aims to trivialize the making of bombastic ascii comments.
Currently supporting the following engines:
- boxes
- cowsay
- figlet
- Comment.nvim
- telescope
- boxes (optional)
- cowsay (optional)
- figlet (optional)
Using packer.nvim
use {
'olidacombe/commentalist.nvim',
requires = {
{ 'nvim-telescope/telescope.nvim' },
{ 'numToStr/Comment.nvim' },
}
}
Call the setup funtion somewhere in your configs
require("commentalist").setup()
-- optionally add a keymap
vim.keymap.set({ "n", "v" }, "<leader>mm", ":Commentalist<CR>")
Use the command :Commentalist
to bring up a telescope previewer allowing
you to browse the output you can expect.
Or if you already know which {renderer}/{font}
you want to apply to a range, call with
the font as an argument, :Commentalist {renderer}/{font}
.
To define your own renderers, you can pass them to setup()
under the renderers
key.
require("commentalist").setup({
renderers = {
my_custom = {
-- a renderer with no fonts
render = function(lines, _)
table.insert(lines, 1, "[com]")
table.insert(lines, "[ment]")
return lines
end,
},
my_other = {
-- a renderer which takes "fonts"
-- you must specify which fonts to offer
render = function(lines, font)
table.insert(lines, 1, "[com:" .. font "]"
table.insert(lines, "[ment:" .. font "]"
return lines
end,
fonts = function(register)
register("a font")
register({ "some", "other", "fonts" })
end,
-- alt: pass a static table of fonts
-- fonts = {"greasy", "oily"},
}
}
})
Your render
function takes as arguments:
lines
- a table of strings, each containing no newlines.font
(optional) - a string indicating whichfont
the user has chosen.
And it must return either:
- a table of strings, each containing no newlines
- a started plenary.job which will return such a table of strings
If a default renderer's binaries are detected, the renderer will be made available automatically. If you don't want that, disable the renderer during setup, e.g.
require("commentalist").setup({
renderers = {
-- you have cowsay installed but don't want to use it with this plugin
cowsay = false
}
})
The healthcheck can be invoked with :checkhealth commentalist
. Any default renderers detected which are not disabled through setup
will result in all fonts becoming available via telescope.
## Checking for required plugins
- OK: plenary installed.
- OK: telescope installed.
## Checking for default renderers
- OK: `figlet` found
- OK: `figlist` found
- OK: `boxes` found
- OK: `cowsay` found