Home

Awesome

A Neovim Plugin Template

A template repository used to create Neovim plugins.

<!-- --><!-- -->
Build Statusunittests documentation luacheck llscheck stylua urlchecker
LicenseLicense-MIT
SocialRSS

Features

Using This Template

  1. Follow the Wiki instructions
  2. Once you're done, remove this section (the rest of this README.md file should be kept / customized to your needs)

Installation

<!-- TODO: (you) - Adjust and add your dependencies as needed here -->
{
    "ColinKennedy/nvim-best-practices-plugin-template",
    dependencies = { "ColinKennedy/mega.cmdparse", "ColinKennedy/mega.logging" },
    -- TODO: (you) - Make sure your first release matches v1.0.0 so it auto-releases!
    version = "v1.*",
}

Configuration

(These are default values)

<!-- TODO: (you) - Remove / Add / Adjust your configuration here -->
{
    "ColinKennedy/nvim-best-practices-plugin-template",
    config = function()
        vim.g.plugin_template_configuration = {
            commands = {
                goodnight_moon = { read = { phrase = "A good book" } },
                hello_world = {
                    say = { ["repeat"] = 1, style = "lowercase" },
                },
            },
            logging = {
                level = "info",
                use_console = false,
                use_file = false,
            },
            tools = {
                lualine = {
                    arbitrary_thing = {
                        color = "Visual",
                        text = " Arbitrary Thing",
                    },
                    copy_logs = {
                        color = "Comment",
                        text = "󰈔 Copy Logs",
                    },
                    goodnight_moon = {
                        color = "Question",
                        text = " Goodnight moon",
                    },
                    hello_world = {
                        color = "Title",
                        text = " Hello, World!",
                    },
                },
                telescope = {
                    goodnight_moon = {
                        { "Foo Book", "Author A" },
                        { "Bar Book Title", "John Doe" },
                        { "Fizz Drink", "Some Name" },
                        { "Buzz Bee", "Cool Person" },
                    },
                    hello_world = { "Hi there!", "Hello, Sailor!", "What's up, doc?" },
                },
            },
        }
    end
}

Lualine

<!-- TODO: (you) - Remove this is you do not want lualine -->

Note: You can customize lualine colors here or using vim.g.plugin_template_configuration.

lualine.nvim

require("lualine").setup {
    sections = {
        lualine_y = {
            -- ... Your other configuration ...
            {
                "plugin_template",
                -- NOTE: These will override default values
                -- display = {
                --     goodnight_moon = {color={fg="#FFFFFF"}, text="Custom message 1"}},
                --     hello_world = {color={fg="#333333"}, text="Custom message 2"},
                -- },
            },
        }
    }
}

Telescope

<!-- TODO: (you) - Remove this is you do not want telescope -->

Note: You can customize telescope colors here or using vim.g.plugin_template_configuration.

telescope.nvim

{
    "nvim-telescope/telescope.nvim",
    cmd = "Telescope",
    config = function()
        -- ... Your other configuration ...
        require("telescope").load_extension("plugin_template")
    end,
    dependencies = {
        "ColinKennedy/nvim-best-practices-plugin-template",
        "nvim-lua/plenary.nvim",
    },
    version = "0.1.*",
},

Colors

This plugin provides two default highlights

Both come with default colors that should look nice. If you want to change them, here's how:

vim.api.nvim_set_hl(0, "PluginTemplateTelescopeEntry", {link="Statement"})
vim.api.nvim_set_hl(0, "PluginTemplateTelescopeSecondary", {link="Question"})

Commands

Here are some example commands:

<!-- TODO: (you) - You'll probably want to change all this or remove it. See --> <!-- plugin/plugin_template.lua for details. -->
" A typical subcommand
:PluginTemplate hello-world say phrase "Hello, World!" " How are you?"
:PluginTemplate hello-world say phrase "Hello, World!" --repeat=2 --style=lowercase

" An example of a flag this repeatable and 3 flags, -a, -b, -c, as one dash
:PluginTemplate arbitrary-thing -vvv -abc -f

" Separate commands with completely separate, flexible APIs
:PluginTemplate goodnight-moon count-sheep 42
:PluginTemplate goodnight-moon read "a book"
:PluginTemplate goodnight-moon sleep -z -z -z

Tests

Initialization

Run this line once before calling any busted command

eval $(luarocks path --lua-version 5.1 --bin)

Running

Run all tests

luarocks test --test-type busted
# Or manually
busted --helper spec/minimal_init.lua .
# Or with Make
make test

Run test based on tags

busted --helper spec/minimal_init.lua . --tags=simple

Tracking Updates

See doc/news.txt for updates.

You can watch this plugin for changes by adding this URL to your RSS feed:

https://github.com/ColinKennedy/nvim-best-practices-plugin-template/commits/main/doc/news.txt.atom

Other Plugins

This template is full of various features. But if your plugin is only meant to be a simple plugin and you don't want the bells and whistles that this template provides, consider instead using nvim-plugin-template