diff --git a/lua/cp/async/setup.lua b/lua/cp/async/setup.lua index 5e899a3..9db5138 100644 --- a/lua/cp/async/setup.lua +++ b/lua/cp/async/setup.lua @@ -98,7 +98,7 @@ function M.setup_problem_async(contest_id, problem_id, language) state.set_test_cases(nil) end - vim.cmd('silent only') + vim.cmd.only({ mods = { silent = true } }) state.set_run_panel_active(false) state.set_contest_id(contest_id) state.set_problem_id(problem_id) diff --git a/spec/async_integration_spec.lua b/spec/async_integration_spec.lua index 2155ff6..fd4b5f8 100644 --- a/spec/async_integration_spec.lua +++ b/spec/async_integration_spec.lua @@ -75,11 +75,12 @@ describe('async integration', function() end, } - vim.cmd = function() end - vim.cmd.e = function() end - vim.cmd.only = function() end - vim.cmd.startinsert = function() end - vim.cmd.stopinsert = function() end + vim.cmd = { + e = function() end, + only = function() end, + startinsert = function() end, + stopinsert = function() end, + } vim.api.nvim_get_current_buf = function() return 1 end diff --git a/spec/async_scraper_spec.lua b/spec/async_scraper_spec.lua index e0c2836..3a9f31a 100644 --- a/spec/async_scraper_spec.lua +++ b/spec/async_scraper_spec.lua @@ -26,7 +26,7 @@ describe('cp.async.scraper', function() end, } - vim.system = function(cmd, _, callback) + vim.system = function(cmd, opts, callback) local result = { code = 0, stdout = '{}', stderr = '' } if cmd[1] == 'ping' then result = { code = 0 } @@ -36,7 +36,17 @@ describe('cp.async.scraper', function() result.stdout = '{"success": true, "tests": [{"input": "1 2", "expected": "3"}], "timeout_ms": 2000, "memory_mb": 256.0, "url": "https://example.com"}' end - callback(result) + + if callback then + callback(result) + else + -- Return object with :wait() for sync calls + return { + wait = function() + return result + end, + } + end end vim.fn.mkdir = function() end diff --git a/spec/async_setup_spec.lua b/spec/async_setup_spec.lua index 984ac20..ccb41bc 100644 --- a/spec/async_setup_spec.lua +++ b/spec/async_setup_spec.lua @@ -69,11 +69,12 @@ describe('cp.async.setup', function() end, } - vim.cmd = function() end - vim.cmd.e = function() end - vim.cmd.only = function() end - vim.cmd.startinsert = function() end - vim.cmd.stopinsert = function() end + vim.cmd = { + e = function() end, + only = function() end, + startinsert = function() end, + stopinsert = function() end, + } vim.api.nvim_get_current_buf = function() return 1 end diff --git a/spec/spec_helper.lua b/spec/spec_helper.lua index db826d7..01c2a04 100644 --- a/spec/spec_helper.lua +++ b/spec/spec_helper.lua @@ -35,10 +35,14 @@ local function setup_vim_mocks() if not vim.cmd then vim.cmd = {} end - vim.cmd.e = function() end - vim.cmd.only = function() end - vim.cmd.split = function() end - vim.cmd.vsplit = function() end + vim.cmd = { + only = function() end, + e = function() end, + split = function() end, + vsplit = function() end, + startinsert = function() end, + stopinsert = function() end, + } if not vim.system then vim.system = function(_) return {