Skip to content

Commit

Permalink
fix(subprocess): catch error getting mode
Browse files Browse the repository at this point in the history
See #37
  • Loading branch information
rcarriga committed Oct 15, 2022
1 parent 272a22b commit 7690967
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions lua/neotest/lib/subprocess.lua
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,9 @@ function M.init()
logger.info("Starting child process")
local parent_address = async.fn.serverstart()
local success
success, child_chan = pcall(async.fn.jobstart, { vim.loop.exepath(), "--embed", "--headless" }, {
local cmd = { vim.loop.exepath(), "--embed", "--headless" }
logger.info("Starting child process with command: " .. table.concat(cmd, " "))
success, child_chan = pcall(async.fn.jobstart, cmd, {
rpc = true,
on_exit = function()
logger.info("Child process exited")
Expand All @@ -36,11 +38,11 @@ function M.init()
logger.error("Failed to start child process", child_chan)
return
end
local mode = async.fn.rpcrequest(child_chan, "nvim_get_mode")
if mode.blocking then
logger.error("Child process is waiting for input at startup. Aborting.")
end
xpcall(function()
local mode = async.fn.rpcrequest(child_chan, "nvim_get_mode")
if mode.blocking then
logger.error("Child process is waiting for input at startup. Aborting.")
end
-- Trigger lazy loading of neotest
async.fn.rpcrequest(child_chan, "nvim_exec_lua", "return require('neotest') and 0", {})
async.fn.rpcrequest(
Expand Down

0 comments on commit 7690967

Please sign in to comment.