Skip to content

Commit 951faae

Browse files
jdxclaude
andcommitted
chore: add LuaLS linting and fix doc annotations
- Add .luarc.json with vfox globals (PLUGIN, RUNTIME) - Add hk.pkl with lua-language-server and stylua linters - Add mise.toml with lint/lint-fix tasks - Fix @field ctx.xxx annotations to use inline type syntax - Format code with stylua Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
1 parent 486347d commit 951faae

File tree

7 files changed

+162
-88
lines changed

7 files changed

+162
-88
lines changed

.luarc.json

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
{
2+
"$schema": "https://raw.githubusercontent.com/LuaLS/vscode-lua/master/setting/schema.json",
3+
"runtime": {
4+
"version": "Lua 5.4"
5+
},
6+
"diagnostics": {
7+
"globals": ["PLUGIN", "RUNTIME"],
8+
"disable": ["duplicate-set-field"]
9+
},
10+
"workspace": {
11+
"checkThirdParty": false
12+
}
13+
}

hk.pkl

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
amends "package://github.com/jdx/hk/releases/download/v1.18.1/hk@1.18.1#/Config.pkl"
2+
import "package://github.com/jdx/hk/releases/download/v1.18.1/hk@1.18.1#/Builtins.pkl"
3+
4+
local linters = new Mapping<String, Step> {
5+
["lua-check"] {
6+
glob = "**/*.lua"
7+
check = "lua-language-server --check ."
8+
}
9+
["stylua"] {
10+
glob = "**/*.lua"
11+
check = "stylua --check {{files}}"
12+
fix = "stylua {{files}}"
13+
}
14+
["actionlint"] {
15+
glob = ".github/workflows/*.{yml,yaml}"
16+
check = "actionlint {{files}}"
17+
}
18+
}
19+
20+
hooks {
21+
["pre-commit"] {
22+
fix = true
23+
stash = "git"
24+
steps = linters
25+
}
26+
["fix"] {
27+
fix = true
28+
steps = linters
29+
}
30+
["check"] {
31+
steps = linters
32+
}
33+
}

hooks/available.lua

Lines changed: 27 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -5,37 +5,37 @@ local json = require("json")
55
--- @param ctx table Context
66
--- @return table Available versions
77
function PLUGIN:Available(ctx)
8-
local results = {}
8+
local results = {}
99

10-
-- Fetch releases from GitHub API (tags show up as releases)
11-
local resp, err = http.get({
12-
url = "https://api.github.com/repos/cisco/ChezScheme/tags?per_page=100"
13-
})
10+
-- Fetch releases from GitHub API (tags show up as releases)
11+
local resp, err = http.get({
12+
url = "https://api.github.com/repos/cisco/ChezScheme/tags?per_page=100",
13+
})
1414

15-
if err ~= nil then
16-
error("Failed to fetch versions: " .. err)
17-
end
15+
if err ~= nil then
16+
error("Failed to fetch versions: " .. err)
17+
end
1818

19-
if resp.status_code ~= 200 then
20-
error("Failed to fetch versions: HTTP " .. resp.status_code)
21-
end
19+
if resp.status_code ~= 200 then
20+
error("Failed to fetch versions: HTTP " .. resp.status_code)
21+
end
2222

23-
local tags = json.decode(resp.body)
23+
local tags = json.decode(resp.body)
2424

25-
for _, tag in ipairs(tags) do
26-
local version = tag.name
27-
-- Remove 'v' prefix if present
28-
if version:sub(1, 1) == "v" then
29-
version = version:sub(2)
30-
end
31-
-- Only include version-like tags (e.g., 10.3.0, 9.5.8)
32-
if version:match("^%d+%.%d+") then
33-
table.insert(results, {
34-
version = version,
35-
note = ""
36-
})
37-
end
38-
end
25+
for _, tag in ipairs(tags) do
26+
local version = tag.name
27+
-- Remove 'v' prefix if present
28+
if version:sub(1, 1) == "v" then
29+
version = version:sub(2)
30+
end
31+
-- Only include version-like tags (e.g., 10.3.0, 9.5.8)
32+
if version:match("^%d+%.%d+") then
33+
table.insert(results, {
34+
version = version,
35+
note = "",
36+
})
37+
end
38+
end
3939

40-
return results
40+
return results
4141
end

hooks/env_keys.lua

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,11 @@
11
--- Returns environment variables to set for this tool.
2-
--- @param ctx table
3-
--- @field ctx.path string Installation path
2+
--- @param ctx {path: string} (Installation path)
43
--- @return table Environment variables
54
function PLUGIN:EnvKeys(ctx)
6-
return {
7-
{
8-
key = "PATH",
9-
value = ctx.path .. "/bin"
10-
}
11-
}
5+
return {
6+
{
7+
key = "PATH",
8+
value = ctx.path .. "/bin",
9+
},
10+
}
1211
end

hooks/post_install.lua

Lines changed: 48 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -2,48 +2,52 @@
22
--- @param ctx table
33
--- @field ctx.rootPath string Installation root path
44
function PLUGIN:PostInstall(ctx)
5-
local os_type = RUNTIME.osType
6-
7-
-- Windows uses the .exe installer, not source compilation
8-
if os_type == "windows" then
9-
print("Windows installation requires the ChezScheme.exe installer from GitHub releases")
10-
print("Please download and run it manually from:")
11-
print("https://github.com/cisco/ChezScheme/releases")
12-
return
13-
end
14-
15-
local root_path = ctx.rootPath
16-
17-
-- The tarball extracts with contents at root level (no top-level directory to strip)
18-
-- We need to run configure and make install
19-
print("Compiling Chez Scheme from source...")
20-
21-
-- Configure with install prefix
22-
local configure_cmd = "cd " .. root_path .. " && ./configure --installprefix=" .. root_path
23-
print("Running: " .. configure_cmd)
24-
local result = os.execute(configure_cmd)
25-
if result ~= 0 and result ~= true then
26-
error("Configure failed")
27-
end
28-
29-
-- Build
30-
local make_cmd = "cd " .. root_path .. " && make"
31-
print("Running: make")
32-
result = os.execute(make_cmd)
33-
if result ~= 0 and result ~= true then
34-
error("Make failed")
35-
end
36-
37-
-- Install to the prefix directory
38-
local install_cmd = "cd " .. root_path .. " && make install"
39-
print("Running: make install")
40-
result = os.execute(install_cmd)
41-
if result ~= 0 and result ~= true then
42-
error("Make install failed")
43-
end
44-
45-
-- Clean up build artifacts to save space (optional)
46-
os.execute("cd " .. root_path .. " && rm -rf boot c examples mats s unicode workarea Makefile configure LOG NOTICE 2>/dev/null")
47-
48-
print("Chez Scheme compilation complete!")
5+
local os_type = RUNTIME.osType
6+
7+
-- Windows uses the .exe installer, not source compilation
8+
if os_type == "windows" then
9+
print("Windows installation requires the ChezScheme.exe installer from GitHub releases")
10+
print("Please download and run it manually from:")
11+
print("https://github.com/cisco/ChezScheme/releases")
12+
return
13+
end
14+
15+
local root_path = ctx.rootPath
16+
17+
-- The tarball extracts with contents at root level (no top-level directory to strip)
18+
-- We need to run configure and make install
19+
print("Compiling Chez Scheme from source...")
20+
21+
-- Configure with install prefix
22+
local configure_cmd = "cd " .. root_path .. " && ./configure --installprefix=" .. root_path
23+
print("Running: " .. configure_cmd)
24+
local result = os.execute(configure_cmd)
25+
if result ~= 0 and result ~= true then
26+
error("Configure failed")
27+
end
28+
29+
-- Build
30+
local make_cmd = "cd " .. root_path .. " && make"
31+
print("Running: make")
32+
result = os.execute(make_cmd)
33+
if result ~= 0 and result ~= true then
34+
error("Make failed")
35+
end
36+
37+
-- Install to the prefix directory
38+
local install_cmd = "cd " .. root_path .. " && make install"
39+
print("Running: make install")
40+
result = os.execute(install_cmd)
41+
if result ~= 0 and result ~= true then
42+
error("Make install failed")
43+
end
44+
45+
-- Clean up build artifacts to save space (optional)
46+
os.execute(
47+
"cd "
48+
.. root_path
49+
.. " && rm -rf boot c examples mats s unicode workarea Makefile configure LOG NOTICE 2>/dev/null"
50+
)
51+
52+
print("Chez Scheme compilation complete!")
4953
end

hooks/pre_install.lua

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,15 @@
11
--- Called before installation to return the download URL.
22
--- Chez Scheme only provides source tarballs, which need to be compiled.
3-
--- @param ctx table
4-
--- @field ctx.version string Version to install
3+
--- @param ctx {version: string} (Version to install)
54
--- @return table File info with URL
65
function PLUGIN:PreInstall(ctx)
7-
local version = ctx.version
6+
local version = ctx.version
87

9-
-- Source tarball URL pattern: csv{version}.tar.gz
10-
local url = "https://github.com/cisco/ChezScheme/releases/download/v" .. version .. "/csv" .. version .. ".tar.gz"
8+
-- Source tarball URL pattern: csv{version}.tar.gz
9+
local url = "https://github.com/cisco/ChezScheme/releases/download/v" .. version .. "/csv" .. version .. ".tar.gz"
1110

12-
return {
13-
url = url,
14-
version = version
15-
}
11+
return {
12+
url = url,
13+
version = version,
14+
}
1615
end

mise.toml

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
[env]
2+
MISE_USE_VERSIONS_HOST = "0"
3+
4+
[tools]
5+
actionlint = "latest"
6+
hk = "latest"
7+
lua = "5.4"
8+
lua-language-server = "latest"
9+
pkl = "latest"
10+
stylua = "latest"
11+
12+
[tasks.format]
13+
description = "Format Lua scripts"
14+
run = "stylua metadata.lua hooks/"
15+
16+
[tasks.lint]
17+
description = "Lint Lua scripts and GitHub Actions using hk"
18+
run = "hk check"
19+
20+
[tasks.lint-fix]
21+
description = "Fix linting issues"
22+
run = "hk fix"
23+
24+
[tasks.ci]
25+
description = "Run all CI checks"
26+
depends = ["lint", "test"]

0 commit comments

Comments
 (0)