Skip to content

Commit 565f619

Browse files
committed
updated formatting and added stylua
1 parent 6c3dc37 commit 565f619

5 files changed

Lines changed: 90 additions & 83 deletions

File tree

.stylua.toml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
# ~/.config/stylua/stylua.toml
2+
indent_type = "Spaces"
3+
indent_width = 2
4+
column_width = 160
5+
line_endings = "Unix"
6+
quote_style = "AutoPreferSingle"
7+
call_parentheses = "None"

tests/codex_spec.lua

Lines changed: 57 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -1,63 +1,63 @@
11
-- tests/codex_spec.lua
22
-- luacheck: globals describe it assert eq
33
-- luacheck: ignore a -- “a” is imported but unused
4-
local a = require("plenary.async.tests")
4+
local a = require 'plenary.async.tests'
55
local eq = assert.equals
66

7-
describe("codex.nvim", function()
8-
before_each(function()
9-
vim.cmd("set noswapfile") -- prevent side effects
10-
vim.cmd("silent! bwipeout!") -- close any open codex windows
11-
end)
12-
13-
it("loads the module", function()
14-
local ok, codex = pcall(require, "codex")
15-
assert(ok, "codex module failed to load")
16-
assert(codex.open, "codex.open missing")
17-
assert(codex.close, "codex.close missing")
18-
assert(codex.toggle, "codex.toggle missing")
19-
end)
20-
21-
it("creates Codex commands", function()
22-
require("codex").setup({ keymaps = {} })
23-
24-
local cmds = vim.api.nvim_get_commands({})
25-
assert(cmds["Codex"], "Codex command not found")
26-
assert(cmds["CodexToggle"], "CodexToggle command not found")
27-
end)
28-
29-
it("opens a floating terminal window", function()
30-
require("codex").setup({ cmd = "echo 'test'" })
31-
require("codex").open()
32-
33-
local win = vim.api.nvim_get_current_win()
34-
local buf = vim.api.nvim_win_get_buf(win)
35-
local ft = vim.api.nvim_buf_get_option(buf, "filetype")
36-
eq(ft, "codex")
37-
38-
require("codex").close()
39-
end)
40-
41-
it("toggles the window", function()
42-
require("codex").setup({ cmd = "echo 'test'" })
43-
44-
require("codex").toggle()
45-
local win1 = vim.api.nvim_get_current_win()
46-
assert(vim.api.nvim_win_is_valid(win1), "Codex window should be open")
47-
48-
require("codex").toggle()
49-
local still_valid = pcall(vim.api.nvim_win_get_buf, win1)
50-
assert(not still_valid, "Codex window should be closed")
51-
end)
52-
53-
it("shows statusline only when job is active but window is not", function()
54-
require("codex").setup({ cmd = "sleep 1000" })
55-
require("codex").open()
56-
57-
vim.defer_fn(function()
58-
require("codex").close()
59-
local status = require("codex").statusline()
60-
eq(status, "[Codex]")
61-
end, 100)
62-
end)
7+
describe('codex.nvim', function()
8+
before_each(function()
9+
vim.cmd 'set noswapfile' -- prevent side effects
10+
vim.cmd 'silent! bwipeout!' -- close any open codex windows
11+
end)
12+
13+
it('loads the module', function()
14+
local ok, codex = pcall(require, 'codex')
15+
assert(ok, 'codex module failed to load')
16+
assert(codex.open, 'codex.open missing')
17+
assert(codex.close, 'codex.close missing')
18+
assert(codex.toggle, 'codex.toggle missing')
19+
end)
20+
21+
it('creates Codex commands', function()
22+
require('codex').setup { keymaps = {} }
23+
24+
local cmds = vim.api.nvim_get_commands {}
25+
assert(cmds['Codex'], 'Codex command not found')
26+
assert(cmds['CodexToggle'], 'CodexToggle command not found')
27+
end)
28+
29+
it('opens a floating terminal window', function()
30+
require('codex').setup { cmd = "echo 'test'" }
31+
require('codex').open()
32+
33+
local win = vim.api.nvim_get_current_win()
34+
local buf = vim.api.nvim_win_get_buf(win)
35+
local ft = vim.api.nvim_buf_get_option(buf, 'filetype')
36+
eq(ft, 'codex')
37+
38+
require('codex').close()
39+
end)
40+
41+
it('toggles the window', function()
42+
require('codex').setup { cmd = "echo 'test'" }
43+
44+
require('codex').toggle()
45+
local win1 = vim.api.nvim_get_current_win()
46+
assert(vim.api.nvim_win_is_valid(win1), 'Codex window should be open')
47+
48+
require('codex').toggle()
49+
local still_valid = pcall(vim.api.nvim_win_get_buf, win1)
50+
assert(not still_valid, 'Codex window should be closed')
51+
end)
52+
53+
it('shows statusline only when job is active but window is not', function()
54+
require('codex').setup { cmd = 'sleep 1000' }
55+
require('codex').open()
56+
57+
vim.defer_fn(function()
58+
require('codex').close()
59+
local status = require('codex').statusline()
60+
eq(status, '[Codex]')
61+
end, 100)
62+
end)
6363
end)

tests/init.lua

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
-- tests/init.lua
22
-- luacheck: globals describe it before_each
33
-- luacheck: ignore async
4-
local async = require("plenary.async.tests")
4+
local async = require 'plenary.async.tests'
55

6-
describe("codex.nvim", function()
7-
it("should load without errors", function()
8-
require("codex")
9-
end)
6+
describe('codex.nvim', function()
7+
it('should load without errors', function()
8+
require 'codex'
9+
end)
1010

11-
it("should respond to basic command", function()
12-
vim.cmd("CodexHello")
13-
-- Add assertion if it triggers some output or state change
14-
end)
11+
it('should respond to basic command', function()
12+
vim.cmd 'CodexHello'
13+
-- Add assertion if it triggers some output or state change
14+
end)
1515
end)

tests/run.lua

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
require("plenary.test_harness").test_directory("tests", {
2-
minimal_init = "tests/minimal_init.lua",
1+
require('plenary.test_harness').test_directory('tests', {
2+
minimal_init = 'tests/minimal_init.lua',
33
})

tests/run_cov.lua

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,24 @@
11
-- run_cov.lua
22

33
-- 1) Load LuaRocks (for luacov, etc.)
4-
pcall(require, "luarocks.loader")
4+
pcall(require, 'luarocks.loader')
55

66
-- 2) Start LuaCov, with tick=true so it flushes periodically
7-
local runner = require("luacov.runner")
8-
runner.init({
9-
statsfile = "luacov.stats.out",
10-
reportfile = "luacov.report.out",
11-
tick = true,
12-
})
7+
local runner = require 'luacov.runner'
8+
runner.init {
9+
statsfile = 'luacov.stats.out',
10+
reportfile = 'luacov.report.out',
11+
tick = true,
12+
}
1313

1414
-- 3) Helper to invoke Plenary’s harness
15-
local harness = require("plenary.test_harness")
15+
local harness = require 'plenary.test_harness'
1616
local function run_tests()
17-
if type(harness.run) == "function" then
18-
harness.run() -- Plenary ≤2023‑11
19-
else
20-
harness.test_directory("tests", {}) -- Plenary ≥2023‑12
21-
end
17+
if type(harness.run) == 'function' then
18+
harness.run() -- Plenary ≤2023‑11
19+
else
20+
harness.test_directory('tests', {}) -- Plenary ≥2023‑12
21+
end
2222
end
2323

2424
-- 4) Run the tests inside xpcall so we always land in the `finally` block
@@ -29,8 +29,8 @@ runner.shutdown()
2929

3030
-- 6) If the harness errored, re‑throw so CI sees a failure
3131
if not ok then
32-
error("Test runner failed:\n" .. err)
32+
error('Test runner failed:\n' .. err)
3333
end
3434

3535
-- 7) Quit *all* windows and exit Neovim cleanly
36-
vim.cmd("qa!")
36+
vim.cmd 'qa!'

0 commit comments

Comments
 (0)