Skip to content

Commit

Permalink
specs, CI, workflows, minor fixes, refactoing
Browse files Browse the repository at this point in the history
added specs and refactoring for utils.eval_lua

added specs and refactoring for utils.eval_lua

more specs

added spec load_console

more specs

added spec for lua_console

added specs lua-console win/buf

finished specs
  • Loading branch information
YaroSpace committed Nov 13, 2024
1 parent 255afdb commit 846d109
Show file tree
Hide file tree
Showing 26 changed files with 1,948 additions and 128 deletions.
16 changes: 16 additions & 0 deletions .busted
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
return {
_all = {
coverage = false,
lpath = "lua/?.lua;lua/?/init.lua;spec/?.lua",
lua = 'spec/nvim-shim.sh',
-- lua = 'nlua',
ROOT = {'spec'}
},
default = {
verbose = true
},
unit = {
ROOT = {'spec/unit'},
verbose = true,
},
}
79 changes: 79 additions & 0 deletions .github/actions/build/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
---
name: 'Nvim Busted Action'
description: 'Test Neovim plugins with Busted'
author: 'Marc Jakobi'
branding:
color: 'purple'
icon: 'moon'
inputs:
nvim_version:
description: |
Version of Neovim to install. Valid values are 'stable', 'nightly' or version tag such
as 'v0.9.2'. Note that this value must exactly match to a tag name when installing the
specific version.
required: false
default: 'stable'
luarocks_version:
description: Version of LuaRocks to install.
required: false
default: '3.11.1'
before:
description: Script to run before running tests.
required: false
default: ''
runs:
using: "composite"
steps:

- uses: actions/cache@v3
id: cache-luarocks
name: Restore cache for luarocks packages.
with:
path: |
~/.luarocks
key: ${{ runner.os }}-luarocks-${{ inputs.luarocks_version }}
restore-keys: |
${{ runner.os }}-luarocks-
- run: date +%F > todays-date
shell: bash
- name: Restore cache for today's Neovim nightly.
if: ${{ inputs.nvim_version }} == 'nightly'
uses: actions/cache@v3
with:
path: _neovim
key: ${{ runner.os }}-x64-${{ hashFiles('todays-date') }}

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

- name: Setup Lua
uses: leso-kn/gh-actions-lua@master
with:
luaVersion: "5.1"

- name: Setup LuaRocks
uses: hishamhm/gh-actions-luarocks@master
# FIXME: caching .luarocks doesn't set up the environment variables (PATH, LUA_PATH, ...) properly
# if: steps.cache-luarocks.outputs.cache-hit != 'true'
with:
luarocksVersion: ${{ inputs.luarocks_version }}

- name: Run 'before' script
if: ${{ inputs.before != '' }}
run: ${{ inputs.before }}
shell: bash

- name: Install busted and nlua
if: steps.cache-luarocks.outputs.cache-hit != 'true'
run: |
luarocks install busted --local
luarocks install luacheck --local
# luarocks install nlua --local
shell: bash

- run: make test
# - run: luarocks test --local
shell: bash
8 changes: 8 additions & 0 deletions .github/workflows/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
version: 2
updates:
# Maintain dependencies for GitHub Actions
- package-ecosystem: github-actions
directory: "/"
schedule:
interval: weekly
open-pull-requests-limit: 10
56 changes: 56 additions & 0 deletions .github/workflows/documentation.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
name: Documentation

on:
push:
branches:
- main
- develop

jobs:
documentation:
name: Documentation
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4

- uses: rhysd/action-setup-vim@v1
with:
neovim: true
version: stable

- name: Create API Documentation
run: |
nvim --version
make api_documentation
- name: Create User Documentation
uses: kdheepak/panvimdoc@main
with:
vimdoc: lua-console.nvim # Output vimdoc project name (required)
# The following are all optional
pandoc: "README.md" # Input pandoc file
version: "Neovim >= 0.8.0"
toc: true # Table of contents
description: A handy scratch pad / REPL / debug console for Lua development and Neovim exploration and configuration
titledatepattern: "%Y %B %d" # Pattern for the date that used in the title
demojify: false # Strip emojis from the vimdoc
dedupsubheadings: true # Add heading to subheading anchor links to ensure that subheadings are unique
treesitter: true # Use treesitter for highlighting codeblocks
ignorerawblocks: true # Ignore raw html blocks in markdown when converting to vimdoc
docmapping: false # Use h4 headers as mapping docs
docmappingprojectname: true # Use project name in tag when writing mapping docs
shiftheadinglevelby: 0 # Shift heading levels by specified number
incrementheadinglevelby: 0 # Increment heading levels by specified number

- name: Generate Tags
run: |
nvim -c 'helptags doc' -c 'quit'
- name: Push Changes
uses: stefanzweifel/git-auto-commit-action@v5
with:
commit_message: "docs(vimdoc): Auto-generate user / API documentation + vimtags"
commit_user_name: "github-actions[bot]"
commit_user_email: "github-actions[bot]@users.noreply.github.com"
commit_author: "github-actions[bot] <github-actions[bot]@users.noreply.github.com>"
23 changes: 23 additions & 0 deletions .github/workflows/luacheck.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
name: Luacheck

on:
pull_request: {}
push:
branches:
- develop
- main
jobs:
luacheck:
name: Luacheck
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v4

- name: Prepare
run: |
sudo apt-get update
sudo apt-get install -y luarocks
sudo luarocks install luacheck
- name: Lint
run: make luacheck
20 changes: 20 additions & 0 deletions .github/workflows/release-luarocks.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# References:
# https://github.com/nvim-neorocks/sample-luarocks-plugin?tab=readme-ov-file#publishing-to-luarocks
# https://github.com/ellisonleao/nvim-plugin-template/blob/922c0d5249076416c5d84e7c0504f1154225a7ab/.github/workflows/release.yml
#
name: Release To LuaRocks

on:
push:
tags:
- 'v*'

jobs:
luarocks-upload:
runs-on: ubuntu-24.04
steps:
- uses: actions/checkout@v4
- name: LuaRocks Upload
uses: nvim-neorocks/luarocks-tag-release@v7
env:
LUAROCKS_API_KEY: ${{ secrets.LUAROCKS_API_KEY }}
22 changes: 22 additions & 0 deletions .github/workflows/test_develop.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
---
name: develop
on:
pull_request: ~
push:
branches:
- develop
jobs:
build:
name: Run tests
runs-on: ubuntu-latest
strategy:
matrix:
neovim_version: ['stable']
# neovim_version: ['nightly', 'stable']

steps:
- uses: actions/checkout@v4
- name: Run tests
uses: ./.github/actions/build
with:
nvim_version: ${{ matrix.neovim_version }}
22 changes: 22 additions & 0 deletions .github/workflows/test_main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
---
name: main
on:
pull_request: ~
push:
branches:
- main
jobs:
build:
name: Run tests
runs-on: ubuntu-latest
strategy:
matrix:
neovim_version: ['stable']
# neovim_version: ['nightly', 'stable']

steps:
- uses: actions/checkout@v4
- name: Run tests
uses: ./.github/actions/build
with:
nvim_version: ${{ matrix.neovim_version }}
29 changes: 29 additions & 0 deletions .luacheckrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
-- Rerun tests only if their modification time changed.
cache = true

std = luajit
codes = true

self = false

-- Reference: https://luacheck.readthedocs.io/en/stable/warnings.html
ignore = {
-- Neovim lua API + luacheck thinks variables like `vim.wo.spell = true` is
-- invalid when it actually is valid. So we have to display rule `W122`.
--
"122",
"631", -- max_line_length
"621", -- incostistant indentation
"611" -- line with whitespace
}

-- Global objects defined by the C code
read_globals = {
"vim",
"Lua_console",
"describe",
"it",
"assert"
}

exclude_files = { }
20 changes: 20 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
.PHONY: api_documentation llscheck luacheck stylua test

api_documentation:
nvim -u scripts/make_api_documentation/minimal_init.lua -l scripts/make_api_documentation/main.lua

llscheck:
llscheck --configpath .luarc.json .

luacheck:
luacheck lua spec # plugin scripts

stylua:
stylua lua plugin scripts spec

test:
eval $(luarocks path --lua-version 5.1 --bin)
busted --run unit

watch:
while sleep 0.1; do ls -d spec/**/*.lua | entr -d -c make test; done
29 changes: 20 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# 💻 Lua console
# 💻 Lua console ![main](https://github.com/yarospace/lua-console.nvim/actions/workflows/test_main.yml/badge.svg?branch=main) ![develop](https://github.com/yarospace/lua-console.nvim/actions/workflows/test_develop.yml/badge.svg?branch=develop) [![LuaRocks](https://img.shields.io/luarocks/v/YaroSpace/lua-console.nvim?logo=lua&color=purple)](https://luarocks.org/modules/YaroSpace/lua-console.nvim)

**lua-console.nvim** is yet another REPL console to execute Lua, configure Neovim, explore its API and settings.
Acts as a user friendly replacement of command mode - messages loop and as a handy scratch pad to store and test code gists.
**lua-console.nvim** - is a handy scratch pad / REPL / debug console for Lua development and Neovim exploration and configuration.
Acts as a user friendly replacement of command mode - messages loop and as a handy scratch pad to store and test your code gists.

<img src="doc/demo.gif">

Expand Down Expand Up @@ -40,31 +40,42 @@ otherwise, install with your favourite package manager and add

## ⚙️ Configuration

Default settings:
<details><summary>Default Settings</summary>

<!-- config:start -->

```lua
opts = {
buffer = {
prepend_result_with = '=> ',
save_path = vim.fn.stdpath('state') .. '/lua-console.lua',
load_on_start = true -- load saved session on Vim start
load_on_start = true -- load saved session on first entry
},
window = {
-- @field height number Percentage of main window
height = 0.6,
border = { '', '' ,'', '', '', '', '', '' },
anchor = 'SW',
border = 'double', -- single|double|rounded
height = 0.6, -- percentage of main window
zindex = 1,
},
mappings = {
toggle = '`',
quit = 'q',
eval = '<CR>',
clear = 'C',
messages = 'M',
save = 'S',
load = 'L'
load = 'L',
resize_up = '<C-Up>',
resize_down = '<C-Down>',
help = '?'
}
}
```

<!-- config:end -->

</details>

## 🚀 Usage (with default mappings)

- Install, hit the mapped key `` ` `` and start exploring.
Expand Down
Loading

0 comments on commit 846d109

Please sign in to comment.