aboutsummaryrefslogtreecommitdiffstats
path: root/lua/lspconfig/async.lua
diff options
context:
space:
mode:
authormeredith <merrilymeredith@users.noreply.github.com>2023-11-14 21:12:59 -0600
committerGitHub <noreply@github.com>2023-11-15 11:12:59 +0800
commitd5d7412ff267b92a11a94e6559d5507c43670a52 (patch)
tree673e51e36844f0d05ff05a72eee90b0cede1f521 /lua/lspconfig/async.lua
parentdocs: update server_configurations.md (diff)
downloadnvim-lspconfig-d5d7412ff267b92a11a94e6559d5507c43670a52.tar
nvim-lspconfig-d5d7412ff267b92a11a94e6559d5507c43670a52.tar.gz
nvim-lspconfig-d5d7412ff267b92a11a94e6559d5507c43670a52.tar.bz2
nvim-lspconfig-d5d7412ff267b92a11a94e6559d5507c43670a52.tar.lz
nvim-lspconfig-d5d7412ff267b92a11a94e6559d5507c43670a52.tar.xz
nvim-lspconfig-d5d7412ff267b92a11a94e6559d5507c43670a52.tar.zst
nvim-lspconfig-d5d7412ff267b92a11a94e6559d5507c43670a52.zip
fix: handle exit code on async run command (#2896)
jobid -1 is returned when the command can't start at all, there shouldn't be any stderr either. normally you could get further detail "errno" style, but i don't see that this is exposed by the job api.
Diffstat (limited to 'lua/lspconfig/async.lua')
-rw-r--r--lua/lspconfig/async.lua18
1 files changed, 15 insertions, 3 deletions
diff --git a/lua/lspconfig/async.lua b/lua/lspconfig/async.lua
index 3421ccc5..eb82b306 100644
--- a/lua/lspconfig/async.lua
+++ b/lua/lspconfig/async.lua
@@ -16,6 +16,8 @@ function M.run_command(cmd)
local stdout = {}
local stderr = {}
+ local exit_code = nil
+
local jobid = vim.fn.jobstart(cmd, {
on_stdout = function(_, data, _)
data = table.concat(data, '\n')
@@ -26,7 +28,8 @@ function M.run_command(cmd)
on_stderr = function(_, data, _)
stderr[#stderr + 1] = table.concat(data, '\n')
end,
- on_exit = function()
+ on_exit = function(_, code, _)
+ exit_code = code
coroutine.resume(co)
end,
stdout_buffered = true,
@@ -34,11 +37,20 @@ function M.run_command(cmd)
})
if jobid <= 0 then
- vim.notify(('[lspconfig] cmd go failed:\n%s'):format(table.concat(stderr, '')), vim.log.levels.WARN)
- return
+ vim.notify(('[lspconfig] unable to run cmd: %s'):format(cmd), vim.log.levels.WARN)
+ return nil
end
coroutine.yield()
+
+ if exit_code ~= 0 then
+ vim.notify(
+ ('[lspconfig] cmd failed with code %d: %s\n%s'):format(exit_code, cmd, table.concat(stderr, '')),
+ vim.log.levels.WARN
+ )
+ return nil
+ end
+
if next(stdout) == nil then
return nil
end