Skip to content

Commit

Permalink
feat(ci): Added CI and badges
Browse files Browse the repository at this point in the history
  • Loading branch information
ColinKennedy committed Oct 24, 2024
1 parent a3efa8e commit 2ff4b05
Show file tree
Hide file tree
Showing 16 changed files with 351 additions and 380 deletions.
32 changes: 6 additions & 26 deletions .github/workflows/documentation.yml
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
name: documentation

on:
push:
branches:
- main
name: documentation

jobs:
api_documentation:
documentation:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
Expand All @@ -20,40 +21,19 @@ jobs:
run: |
nvim --version
make api_documentation
user_documentation:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Create User Documentation
uses: kdheepak/panvimdoc@main
with:
vimdoc: plugin-template
version: "Neovim >= 0.8.0"
demojify: true
treesitter: true
tags:
runs-on: ubuntu-latest
needs: [api_documentation, user_documentation]
steps:
- name: Setup Neovim
uses: rhysd/action-setup-vim@v1
with:
neovim: true
version: stable

- name: Checkout plugin-template
uses: actions/checkout@v4
with:
repository: ColinKennedy/nvim-best-practices-plugin-template
path: neovim_plugin

- name: Generate Tags
run: |
# nvim -c 'helptags doc' -c 'quit'
# push:
runs-on: ubuntu-latest
needs: [tags]
steps:
nvim -c 'helptags doc' -c 'quit'
- name: Push Changes
uses: stefanzweifel/git-auto-commit-action@v4
with:
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/luacheck.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
---
on: [pull_request]
name: luacheck

on: [pull_request]

jobs:
luacheck:
name: Luacheck
Expand Down
2 changes: 2 additions & 0 deletions .github/workflows/news.yml
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
# Reference: https://github.com/neovim/neovim/blob/9762c5e3406cab8152d8dd161c0178965d841676/.github/workflows/news.yml
name: "news.txt"

on:
pull_request:
types: [opened, synchronize, reopened, ready_for_review, labeled, unlabeled]
branches:
- main

jobs:
check:
runs-on: ubuntu-latest
Expand Down
2 changes: 2 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
# Reference: https://github.com/ellisonleao/nvim-plugin-template/blob/922c0d5249076416c5d84e7c0504f1154225a7ab/.github/workflows/release.yml
name: release

on:
push:
tags:
- 'v*'

jobs:
luarocks-upload:
runs-on: ubuntu-22.04
Expand Down
7 changes: 5 additions & 2 deletions .github/workflows/stylua.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
---
on: [pull_request]
name: stylua

on:
pull_request:
branches:
- main

jobs:
stylua:
name: stylua
Expand Down
45 changes: 45 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
name: test

on:
pull_request:
types: [opened, synchronize, reopened, ready_for_review]
branches:
- main

jobs:
test:
strategy:
matrix:
os: [ubuntu-latest, macos-latest]
neovim: [v0.10.0, stable, nightly]

runs-on: ${{ matrix.os }}
name: "OS: ${{ matrix.os }} - Neovim: ${{ matrix.neovim }}"

steps:
- uses: actions/checkout@master

- uses: leafo/gh-actions-lua@v10
with:
# Neovim is compiled with LuaJIT so we might as well match. But it
# doesn't look like we can match it exactly.
#
# Reference:
# https://github.com/leafo/gh-actions-lua/issues/49#issuecomment-2295071198
#
luaVersion: "luajit-openresty"

- uses: leafo/gh-actions-luarocks@v4

- uses: rhysd/action-setup-vim@v1
with:
neovim: true
version: ${{ matrix.neovim }}

- name: build
run: |
luarocks test plugin-template-scm-1.rockspec --prepare
- name: test
run: |
luarocks test --test-type busted
21 changes: 9 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,22 +1,16 @@
# 🚧 Under Construction 🚧

This repository doesn't have all GitHub CI actions working yet but is available
as an early preview. We will update docs/news.txt once it's ready.

Add https://github.com/ColinKennedy/nvim-best-practices-plugin-template/commits/main/doc/news.txt.atom
to your RSS feed so you don't miss it!

# A Neovim Plugin Template

![GitHub Workflow Status](https://img.shields.io/github/actions/workflow/status/ColinKennedy/nvim-best-practices-plugin-template/test.yml?branch=main&style=for-the-badge)
![Lua](https://img.shields.io/badge/Made%20with%20Lua-blueviolet.svg?style=for-the-badge&logo=lua)
| <!-- --> | <!-- --> |
|--------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| Build Status | [![Unittests](https://img.shields.io/github/actions/workflow/status/ColinKennedy/nvim-best-practices-plugin-template/test.yml?branch=fix_todo_notes_005&style=for-the-badge&label=Unittests)](https://github.com/ColinKennedy/nvim-best-practices-plugin-template/actions/workflows/test.yml) [![Documentation](https://img.shields.io/github/actions/workflow/status/ColinKennedy/nvim-best-practices-plugin-template/documentation.yml?branch=fix_todo_notes_005&style=for-the-badge&label=Documentation)](https://github.com/ColinKennedy/nvim-best-practices-plugin-template/actions/workflows/documentation.yml) [![Luacheck](https://img.shields.io/github/actions/workflow/status/ColinKennedy/nvim-best-practices-plugin-template/luacheck.yml?branch=fix_todo_notes_005&style=for-the-badge&label=Luacheck)](https://github.com/ColinKennedy/nvim-best-practices-plugin-template/actions/workflows/luacheck.yml) [![Stylua](https://img.shields.io/github/actions/workflow/status/ColinKennedy/nvim-best-practices-plugin-template/stylua.yml?branch=fix_todo_notes_005&style=for-the-badge&label=Stylua)](https://github.com/ColinKennedy/nvim-best-practices-plugin-template/actions/workflows/stylua.yml) \| |
| License | ![License-MIT](https://img.shields.io/badge/License-MIT-blue?style=for-the-badge) |

A template repository for Neovim plugins.
A template repository used to create Neovim plugins.


# Features
- Follows [nvim-best-practices](https://github.com/nvim-neorocks/nvim-best-practices)
- Fast start-up (the plugin is super defer-loaded. < 1 ms guarantee)
- Fast start-up (~1 ms)
- Auto-release to [luarocks](https://luarocks.org)
- Automated user documentation (using [panvimdoc](https://github.com/kdheepak/panvimdoc))
- Automated API documentation (using [mini.doc](https://github.com/echasnovski/mini.doc))
Expand All @@ -29,6 +23,9 @@ A template repository for Neovim plugins.
- [RSS feed support](tracking-updates)
- Built-in logging to stdout / files
- Unittests use the full power of native [busted](https://olivinelabs.com/busted)
- Automated testing matrix supports 6 Neovim/OS combinations
- neovim: `[v0.10.0, stable, nightly]`
- os: `[ubuntu-latest, macos-latest]`
- 100% Lua
- Uses [Semantic Versioning](https://semver.org)
- Integrations
Expand Down
32 changes: 0 additions & 32 deletions TODO.md

This file was deleted.

47 changes: 3 additions & 44 deletions doc/news.txt
Original file line number Diff line number Diff line change
@@ -1,59 +1,18 @@
*plugin-template-news.txt*

Notable changes since PluginTemplate 0.1
Notable changes since PluginTemplate 1.0


===============================================================================
NEW FEATURES *plugin-template-new-features*

GENERAL

- 100% Lua
- LuaCATS <https://luals.github.io/wiki/annotations/> annotations and type-hints, everywhere
- No external dependencies

CI

- Github actions for:
- PR reviews - Reminds users to update `doc/news.txt`
- `StyLua`
- `llscheck`
- `luacheck`
- `luarocks`
- `panvimdoc`
- RSS feed support

CLI

- Added nargs support to `cmdparse` and other features

START UP

- Fast start-up (the plugin is defer-loaded)
- Follows nvim-best-practices <https://github.com/nvim-neorocks/nvim-best-practices>

COMMANDS

- Built-in Vim commands with auto-completion

TESTS

- Unittests use the full power of native busted <https://olivinelabs.com/busted>

TOOLS

Integrates with

- lualine.nvim <https://github.com/nvim-lualine/lualine.nvim>
- telescope.nvim <https://github.com/nvim-telescope/telescope.nvim>
- `:checkhealth`
We're live!


===============================================================================
BREAKING CHANGES *plugin-template-new-breaking*

CLI
n/a

- Replaced the old raw-lua-table-based API with a class-based API.

vim:tw=78:ts=8:noet:ft=help:norl:
4 changes: 2 additions & 2 deletions doc/plugin-template.txt
Original file line number Diff line number Diff line change
Expand Up @@ -45,15 +45,15 @@ A template repository for Neovim plugins.
- Follows nvim-best-practices <https://github.com/nvim-neorocks/nvim-best-practices>
- Fast start-up (the plugin is super defer-loaded. < 1 ms guarantee)
- Auto-release to luarocks <https://luarocks.org>
- Automated User documentation (using panvimdoc <https://github.com/kdheepak/panvimdoc>)
- Automated user documentation (using panvimdoc <https://github.com/kdheepak/panvimdoc>)
- Automated API documentation (using mini.doc <https://github.com/echasnovski/mini.doc>)
- Vimtags generation
- Built-in Vim commands
- A high quality command mode parser
- Auto-completes your commands at any cursor position
- No external dependencies <https://github.com/ColinKennedy/nvim-best-practices-plugin-template/wiki/External-Dependencies-Disclaimer>
- LuaCATS <https://luals.github.io/wiki/annotations/>annotations and type-hints, everywhere
- RSS feed support
- RSS feed support <tracking-updates>
- Built-in logging to stdout / files
- Unittests use the full power of native busted <https://olivinelabs.com/busted>
- 100% Lua
Expand Down
21 changes: 9 additions & 12 deletions lua/plugin_template/_cli/cli_subcommand.lua
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@
---@module 'plugin_template._cli.cli_subcommand'
---

local help_message = require("plugin_template._cli.cmdparse.help_message")

local M = {}

---@class argparse.SubcommandRunnerOptions
Expand Down Expand Up @@ -261,17 +259,15 @@ end
---
function M.make_parser_completer(parser_creator)
local function runner(_, all_text, _)
local configuration = require("plugin_template._core.configuration")
configuration.initialize_data_if_needed()

local parser = parser_creator()
local column = vim.fn.getcmdpos()

return parser:get_completion(all_text, column)
end

-- NOTE: Initialize only once
local configuration = require("plugin_template._core.configuration")

configuration.initialize_data_if_needed()

return runner
end

Expand All @@ -285,6 +281,7 @@ function M.make_subcommand_completer(prefix, subcommands)
local function runner(latest_text, all_text, _)
local configuration = require("plugin_template._core.configuration")
configuration.initialize_data_if_needed()

local completion = _get_subcommand_completion(all_text, prefix, subcommands)

if completion then
Expand Down Expand Up @@ -381,6 +378,11 @@ function M.make_subcommand_triager(subcommands)
---@param opts argparse.SubcommandRunnerOptions The parsed user options.
---
local function runner(opts)
local configuration = require("plugin_template._core.configuration")
configuration.initialize_data_if_needed()

local help_message = require("plugin_template._cli.cmdparse.help_message")

local success, result = pcall(function()
_runner(opts)
end)
Expand All @@ -398,11 +400,6 @@ function M.make_subcommand_triager(subcommands)
end
end

-- NOTE: Initialize only once
local configuration = require("plugin_template._core.configuration")

configuration.initialize_data_if_needed()

return runner
end

Expand Down
13 changes: 12 additions & 1 deletion lua/plugin_template/_core/tabler.lua
Original file line number Diff line number Diff line change
Expand Up @@ -38,13 +38,24 @@ end
---
function M.get_value(data, items)
local current = data
local found = {}
local count = #items

for _, item in ipairs(items) do
for index = 1, count do
local item = items[index]
current = current[item]

if current == nil then
return nil
end

table.insert(found, item)

local type_ = type(current)

if index < count and type_ ~= "table" then
error(string.format("%s: expected table, got %s", vim.fn.join(found, "."), type_), 0)
end
end

return current
Expand Down
Loading

0 comments on commit 2ff4b05

Please sign in to comment.