Skip to content

olidacombe/commentalist.nvim

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

19 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Commentalist

This plugin aims to trivialize the making of bombastic ascii comments.

Preview

Currently supporting the following engines:

  • boxes
  • cowsay
  • figlet

Dependencies

Installation

Using packer.nvim

use {
    'olidacombe/commentalist.nvim',
    requires = {
        { 'nvim-telescope/telescope.nvim' },
        { 'numToStr/Comment.nvim' },
    }
}

Setup

Call the setup funtion somewhere in your configs

require("commentalist").setup()

-- optionally add a keymap
vim.keymap.set({ "n", "v" }, "<leader>mm", ":Commentalist<CR>")

Usage

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}.

Custom Renderers

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:

  1. lines - a table of strings, each containing no newlines.
  2. font (optional) - a string indicating which font 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

Disable default renderer

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
	}
})

checkhealth

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

About

Easily create ascii art comments in text files

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages