Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,26 @@ jobs:
- name: Check formatting
run: make fmt-check

lint:
name: Lint
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- name: Setup Lua and LuaRocks
uses: leafo/gh-actions-lua@v11
with:
luaVersion: "5.1"

- name: Setup LuaRocks
uses: leafo/gh-actions-luarocks@v5

- name: Install luacheck
run: luarocks install luacheck

- name: Run lint
run: make lint

test:
name: Test
runs-on: ubuntu-latest
Expand Down
19 changes: 19 additions & 0 deletions .luacheckrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
std = "lua51"

globals = {
"vim",
}

files["tests/**/*.lua"] = {
globals = {
"vim",
"describe",
"it",
"before_each",
"after_each",
"setup",
"teardown",
"pending",
"assert",
},
}
6 changes: 5 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
.PHONY: test test-file clean fmt fmt-check
.PHONY: test test-file clean fmt fmt-check lint

# Test runner
PLENARY_DIR ?= /tmp/plenary.nvim
Expand Down Expand Up @@ -39,3 +39,7 @@ fmt:
# Check Lua formatting
fmt-check:
stylua --check lua plugin tests

# Lint Lua files
lint:
luacheck lua plugin tests
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -231,6 +231,12 @@ make fmt
make fmt-check
```

* Run lint:

```sh
make lint
```

* Run tests:

```sh
Expand Down
2 changes: 1 addition & 1 deletion lua/comment-translate/commands.lua
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ end
local function disable_all_buffers()
ui.virtual_text.clear_all()

for buf, state in pairs(immersive_state) do
for _, state in pairs(immersive_state) do
state.enabled = false
bump_token(state)
end
Expand Down
3 changes: 1 addition & 2 deletions tests/integration_spec.lua
Original file line number Diff line number Diff line change
Expand Up @@ -291,7 +291,6 @@ describe('integration', function()

describe('manual hover mode', function()
local config
local commands

before_each(function()
for name, _ in pairs(package.loaded) do
Expand All @@ -312,7 +311,7 @@ describe('integration', function()
},
})

commands = require('comment-translate.commands')
require('comment-translate.commands')
end)

it('should have auto hover disabled in config', function()
Expand Down
8 changes: 4 additions & 4 deletions tests/llm_spec.lua
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ describe('translate.llm', function()
}

local FakeJob = {}
function FakeJob:new(opts)
function FakeJob.new(_, opts)
job_state.new_calls = job_state.new_calls + 1
job_state.last_opts = opts
return setmetatable({
Expand All @@ -43,11 +43,11 @@ describe('translate.llm', function()
result = function()
return { job_state.stdout }
end,
start = function(self)
start = function(job)
for _, line in ipairs(job_state.stderr_lines or {}) do
self._opts.on_stderr(nil, line)
job._opts.on_stderr(nil, line)
end
self._opts.on_exit(self, job_state.exit_code)
job._opts.on_exit(job, job_state.exit_code)
end,
},
})
Expand Down
4 changes: 3 additions & 1 deletion tests/minimal_init.lua
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
---Minimal init for running tests
---Usage: nvim --headless -u tests/minimal_init.lua -c "PlenaryBustedDirectory tests/ {minimal_init = 'tests/minimal_init.lua'}"
---Usage:
---nvim --headless -u tests/minimal_init.lua
---Then run PlenaryBustedDirectory with this minimal_init.

local plenary_dir = os.getenv('PLENARY_DIR') or '/tmp/plenary.nvim'
local is_not_a_directory = vim.fn.isdirectory(plenary_dir) == 0
Expand Down
Loading