Skip to content

Commit 2fc47ec

Browse files
authored
chore: use luals lint (#99)
1 parent 3d6cbf3 commit 2fc47ec

8 files changed

Lines changed: 169 additions & 7 deletions

File tree

.github/workflows/ci.yml

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,20 @@ permissions:
1010

1111
jobs:
1212
checks:
13-
name: ${{ matrix.check }}
13+
name: ${{ matrix.check }} ${{ matrix.version || '' }}
1414
strategy:
1515
matrix:
16-
os: [ubuntu-latest]
17-
check: [formatting, test]
16+
include:
17+
- os: ubuntu-latest
18+
check: formatting
19+
- os: ubuntu-latest
20+
check: linting
21+
- os: ubuntu-latest
22+
check: test
23+
version: stable
24+
- os: ubuntu-latest
25+
check: test
26+
version: nightly
1827
runs-on: ${{ matrix.os }}
1928
steps:
2029
- name: Checkout code
@@ -32,12 +41,17 @@ jobs:
3241
if: ${{ matrix.check == 'test' }}
3342
uses: y3owk1n/nvs@main
3443
with:
35-
version: stable
44+
version: ${{ matrix.version }}
45+
use-global-cache: true
3646

3747
- name: Run just fmt-check
3848
if: ${{ matrix.check == 'formatting' }}
3949
run: devbox run -- just fmt-check
4050

51+
- name: Run just lint
52+
if: ${{ matrix.check == 'linting' }}
53+
run: devbox run -- just lint
54+
4155
- name: Run just test
4256
if: ${{ matrix.check == 'test' }}
4357
run: devbox run -- just test

.luarc.json

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
{
2+
"Lua": {
3+
"runtime": {
4+
"version": "LuaJIT",
5+
"path": ["lua/?.lua", "lua/?/init.lua"]
6+
},
7+
"workspace": {
8+
"library": ["${3rd}/neovim/library", "${3rd}/luv/library", "lua/types"],
9+
"checkThirdParty": false,
10+
"ignoreDir": [".devbox", "**/.devbox/**"],
11+
"ignoreSubmodules": true
12+
},
13+
"diagnostics": {
14+
"globals": ["vim", "assert", "it", "before_each", "after_each", "describe"],
15+
"ignoredFiles": "Disable"
16+
}
17+
}
18+
}

Justfile

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,14 @@ fmt-check:
1313
fmt:
1414
stylua --config-path=.stylua.toml lua
1515

16+
lint:
17+
@if lua-language-server --configpath=.luarc.json --check=. --check_format=pretty --checklevel=Warning 2>&1 | grep -E 'Warning|Error'; then \
18+
echo "LSP lint failed"; \
19+
exit 1; \
20+
else \
21+
echo "LSP lint passed"; \
22+
fi
23+
1624
test:
1725
@echo "Running tests in headless Neovim using test_init.lua..."
1826
nvim -l tests/minit.lua --minitest

devbox.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"$schema": "https://raw.githubusercontent.com/jetify-com/devbox/0.16.0/.schema/devbox.schema.json",
3-
"packages": ["vimcats@1.1.1", "just@1.43.1", "stylua@2.3.1"],
3+
"packages": ["vimcats@1.1.1", "just@1.43.1", "stylua@2.3.1", "lua-language-server@3.15.0"],
44
"shell": {
55
"init_hook": ["echo 'Welcome to devbox!' > /dev/null"],
66
"scripts": {

devbox.lock

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,54 @@
8989
}
9090
}
9191
},
92+
"lua-language-server@3.15.0": {
93+
"last_modified": "2025-11-23T21:50:36Z",
94+
"resolved": "github:NixOS/nixpkgs/ee09932cedcef15aaf476f9343d1dea2cb77e261#lua-language-server",
95+
"source": "devbox-search",
96+
"version": "3.15.0",
97+
"systems": {
98+
"aarch64-darwin": {
99+
"outputs": [
100+
{
101+
"name": "out",
102+
"path": "/nix/store/5rddfc8p6ic2cn31b1ilcjnas3lisim6-lua-language-server-3.15.0",
103+
"default": true
104+
}
105+
],
106+
"store_path": "/nix/store/5rddfc8p6ic2cn31b1ilcjnas3lisim6-lua-language-server-3.15.0"
107+
},
108+
"aarch64-linux": {
109+
"outputs": [
110+
{
111+
"name": "out",
112+
"path": "/nix/store/lxbxapmph15bvhiwyrbrvpw7ghzh3jjn-lua-language-server-3.15.0",
113+
"default": true
114+
}
115+
],
116+
"store_path": "/nix/store/lxbxapmph15bvhiwyrbrvpw7ghzh3jjn-lua-language-server-3.15.0"
117+
},
118+
"x86_64-darwin": {
119+
"outputs": [
120+
{
121+
"name": "out",
122+
"path": "/nix/store/7xrdxsn208ix50i6xkyd4llqlg6657sk-lua-language-server-3.15.0",
123+
"default": true
124+
}
125+
],
126+
"store_path": "/nix/store/7xrdxsn208ix50i6xkyd4llqlg6657sk-lua-language-server-3.15.0"
127+
},
128+
"x86_64-linux": {
129+
"outputs": [
130+
{
131+
"name": "out",
132+
"path": "/nix/store/24zcxhj12kb6mvp4y16f190wjxajvdhz-lua-language-server-3.15.0",
133+
"default": true
134+
}
135+
],
136+
"store_path": "/nix/store/24zcxhj12kb6mvp4y16f190wjxajvdhz-lua-language-server-3.15.0"
137+
}
138+
}
139+
},
92140
"stylua@2.3.1": {
93141
"last_modified": "2025-11-23T21:50:36Z",
94142
"resolved": "github:NixOS/nixpkgs/ee09932cedcef15aaf476f9343d1dea2cb77e261#stylua",

lua/time-machine/types.lua

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ local M = {}
1414
---@alias TimeMachine.SplitDirection
1515
---| '"left"'
1616
---| '"right"'
17-
---@alias TimeMachine.SeqMap table<integer, string|integer[]>
17+
---@alias TimeMachine.SeqMap table<integer, string|integer>
1818

1919
---@class TimeMachine.Config
2020
---@field diff_tool? TimeMachine.DiffTool The diff tool to use
@@ -59,4 +59,18 @@ local M = {}
5959
---@field seq integer The sequence number
6060
---@field column integer The column number
6161

62+
---@class vim.fn.undotree.entry
63+
---@field seq integer The sequence number
64+
---@field time integer The timestamp
65+
---@field alt vim.fn.undotree.entry[] Alternative entries (branches)
66+
---@field save integer|nil Save number if it's a save point
67+
68+
---@class vim.fn.undotree.ret
69+
---@field seq_cur integer The current sequence number
70+
---@field entries vim.fn.undotree.entry[] The undo tree entries
71+
72+
---@alias vim.diff.Opts table
73+
---@alias vim.text.diff.Opts table
74+
---@alias vim.api.keyset.win_config table
75+
6276
return M

lua/time-machine/window.lua

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@ function M.create_native_float_win(bufnr, title)
2626
local footer_text =
2727
string.format("Press `%s` to exit", keymaps.close or "q")
2828

29-
---@type vim.api.keyset.win_config
3029
local win_opts = {
3130
relative = "editor",
3231
border = winborder,

lua/types/busted.lua

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
---@meta
2+
3+
---@class AssertIs
4+
---@field ["nil"] fun(...): any
5+
---@field truthy fun(...): any
6+
---@field falsy fun(...): any
7+
---@field number fun(...): any
8+
---@field string fun(...): any
9+
---@field table fun(...): any
10+
---@field boolean fun(...): any
11+
---@field ["function"] fun(...): any
12+
---@field is_true fun(...): any
13+
---@field is_false fun(...): any
14+
---@field is_nil fun(...): any
15+
---@field is_number fun(...): any
16+
---@field is_boolean fun(...): any
17+
---@field is_string fun(...): any
18+
---@field is_table fun(...): any
19+
---@field is_function fun(...): any
20+
---@field is_truthy fun(...): any
21+
22+
---@class AssertAre
23+
---@field same fun(...): any
24+
25+
---@class AssertLib
26+
---@field is AssertIs
27+
---@field are AssertAre
28+
---@field equal fun(...): any
29+
---@field equals fun(...): any
30+
---@field matches fun(...): any
31+
---@field spy table
32+
33+
-- Runtime stub with all fields so LSP recognizes them
34+
assert = {
35+
is = {
36+
["nil"] = function(...) end,
37+
truthy = function(...) end,
38+
falsy = function(...) end,
39+
number = function(...) end,
40+
string = function(...) end,
41+
table = function(...) end,
42+
boolean = function(...) end,
43+
["function"] = function(...) end,
44+
is_true = function(...) end,
45+
is_false = function(...) end,
46+
is_nil = function(...) end,
47+
is_number = function(...) end,
48+
is_boolean = function(...) end,
49+
is_string = function(...) end,
50+
is_table = function(...) end,
51+
is_function = function(...) end,
52+
is_truthy = function(...) end,
53+
},
54+
are = {
55+
same = function(...) end,
56+
},
57+
equal = function(...) end,
58+
equals = function(...) end,
59+
matches = function(...) end,
60+
spy = {},
61+
}

0 commit comments

Comments
 (0)