Skip to content

Commit 408aee7

Browse files
committed
chore(lua): revise luarocks setup to simplify
1 parent 27b0708 commit 408aee7

4 files changed

Lines changed: 13 additions & 5 deletions

File tree

‎NEOTEST.md‎

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,8 @@ end
5454
Note: if `vim.g.test_root` is not set, we will default to using either the output of `require('project').get_project_root()` or `vim.fn.getcwd()` as fallbacks.
5555

5656
## 2. Monorepo Services (Mocha + NPM Workspaces)
57-
**Structure:** `services/{service_name}/.../{file}.{spec|integration|e2e}.ts` **Behavior**: Maps `spec` to `unit` and executes the specific workspace script.
57+
**Structure:** `services/{service_name}/.../{file}.{spec|integration|e2e}.ts`\
58+
**Behavior**: Maps `spec` to `unit` and executes the specific workspace script.
5859

5960
```lua
6061
-- luacheck: globals vim
@@ -99,7 +100,8 @@ end
99100
```
100101

101102
## 3. Neovim Plugin (luarocks + busted + nlua)
102-
**Structure:** `tests/.../{file}_spec.lua`, with locally installed `busted` and `nlua` via `luarocks` **Hint:** run `luarocks test --prepare` in the root of the project to setup environment
103+
**Structure:** `tests/.../{file}_spec.lua`, with locally installed `busted` and `nlua` via `luarocks`\
104+
**Hint:** run `luarocks init --lua-version 5.1 && eval $(luarocks path) && luarocks test --prepare` in the root of the project to setup environment
103105

104106
```lua
105107
-- luacheck: globals vim
@@ -108,14 +110,16 @@ vim.g.lint_enable_luacheck = false
108110

109111
-- Helper to run a command and return trimmed output
110112
local function lr_cmd(arg)
111-
local cmd = string.format('luarocks path %s --lua-version 5.1', arg)
113+
local cmd = string.format('luarocks path %s', arg)
112114
return vim.fn.system(cmd):gsub('%s+', '') -- Run and remove whitespace/newlines
113115
end
114116

115117
local rock_path = lr_cmd('--lr-path')
116118
local rock_cpath = lr_cmd('--lr-cpath')
117119

118120
-- useful for running `lurocks test` inside a terminal without setting the path
121+
-- equivalent to `eval $(luarocks path)` in bash
122+
vim.env.PATH = vim.env.PATH .. ':' .. lr_cmd('--lr-bin')
119123
vim.env.LUA_PATH = rock_path
120124
vim.env.LUA_CPATH = rock_cpath
121125

‎home/.luarocks/config-5.1.lua‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
--luacheck: ignore
22

3-
lua_version = '5.1'
43
local_by_default = true
54

65
variables = {

‎home/.luarocks/config-5.4.lua‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
--luacheck: ignore
2+
3+
local_by_default = true
Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,3 @@
1-
return "5.1"
1+
-- subject to change, ensures `local_by_default` gets applied even
2+
-- even if the luarocks package used defaults to a different version of lua
3+
return '5.4'

0 commit comments

Comments
 (0)