Skip to content

Commit dcd6bb1

Browse files
committed
test: Add luacheck
1 parent 95a45b8 commit dcd6bb1

File tree

4 files changed

+27
-9
lines changed

4 files changed

+27
-9
lines changed

.github/workflows/tests.yaml

+12
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,18 @@ jobs:
2424
version: latest
2525
args: --color always --check lua/ tests/
2626

27+
luacheck:
28+
runs-on: ubuntu-22.04
29+
steps:
30+
- uses: actions/checkout@v4
31+
- name: Prepare
32+
run: |
33+
sudo apt-get update
34+
sudo apt-get install -y luarocks
35+
sudo luarocks install luacheck
36+
- name: Lint
37+
run: luacheck lua/
38+
2739
unit_test:
2840
runs-on: ubuntu-latest
2941

.luacheckrc

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
read_globals = { "vim" }

lua/debugprint/init.lua

+7-7
Original file line numberDiff line numberDiff line change
@@ -174,20 +174,18 @@ end
174174

175175
local cache_request = {}
176176

177-
---@param motion string
178177
---@return nil
179-
M.debugprint_operatorfunc_regular = function(motion)
178+
M.debugprint_operatorfunc_regular = function()
180179
addline(cache_request)
181180
utils_operator.set_callback(
182181
"v:lua.require'debugprint'.debugprint_operatorfunc_regular"
183182
)
184183
end
185184

186-
---@param motion string
187185
---@return nil
188-
M.debugprint_operatorfunc_motion = function(motion)
186+
M.debugprint_operatorfunc_motion = function()
189187
cache_request.variable_name = utils_buffer.get_operator_selection()
190-
M.debugprint_operatorfunc_regular(motion)
188+
M.debugprint_operatorfunc_regular()
191189
end
192190

193191
---@param opts DebugprintFunctionOptionsInternal
@@ -209,8 +207,9 @@ M.debugprint_regular = function(opts)
209207
end
210208

211209
cache_request = opts
212-
vim.go.operatorfunc =
210+
utils_operator.set_operatorfunc(
213211
"v:lua.require'debugprint'.debugprint_operatorfunc_regular"
212+
)
214213
return "g@l"
215214
end
216215

@@ -228,8 +227,9 @@ M.debugprint = function(opts)
228227

229228
if func_opts.motion == true then
230229
cache_request = func_opts
231-
vim.go.operatorfunc =
230+
utils_operator.set_operatorfunc(
232231
"v:lua.require'debugprint'.debugprint_operatorfunc_motion"
232+
)
233233
return "g@"
234234
else
235235
cache_request = {}

lua/debugprint/utils/operator.lua

+7-2
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,17 @@ local M = {}
33
---@return nil
44
M.NOOP = function() end
55

6+
---@param value string
7+
M.set_operatorfunc = function(value)
8+
vim.api.nvim_set_option_value("operatorfunc", value, {})
9+
end
10+
611
---@param func_name string
712
---@return nil
813
M.set_callback = function(func_name)
9-
vim.go.operatorfunc = "v:lua.require'debugprint.utils.operator'.NOOP"
14+
M.set_operatorfunc("v:lua.require'debugprint.utils.operator'.NOOP")
1015
vim.cmd("normal! g@l")
11-
vim.go.operatorfunc = func_name
16+
M.set_operatorfunc(func_name)
1217
end
1318

1419
return M

0 commit comments

Comments
 (0)