aboutsummaryrefslogtreecommitdiffstats
path: root/lua/nvim-lsp-installer
diff options
context:
space:
mode:
authorWilliam Boman <william@redwill.se>2021-09-16 15:54:30 +0200
committerGitHub <noreply@github.com>2021-09-16 15:54:30 +0200
commitd5400767fa44dc549a8fc6b1b1b1c7c233f9b341 (patch)
tree6cc37974c1f636187bbef5d44823a8f39f5040c2 /lua/nvim-lsp-installer
parentui/status-win: show relative install date next to installed servers (diff)
downloadmason-d5400767fa44dc549a8fc6b1b1b1c7c233f9b341.tar
mason-d5400767fa44dc549a8fc6b1b1b1c7c233f9b341.tar.gz
mason-d5400767fa44dc549a8fc6b1b1b1c7c233f9b341.tar.bz2
mason-d5400767fa44dc549a8fc6b1b1b1c7c233f9b341.tar.lz
mason-d5400767fa44dc549a8fc6b1b1b1c7c233f9b341.tar.xz
mason-d5400767fa44dc549a8fc6b1b1b1c7c233f9b341.tar.zst
mason-d5400767fa44dc549a8fc6b1b1b1c7c233f9b341.zip
better error messages (#92)
Diffstat (limited to 'lua/nvim-lsp-installer')
-rw-r--r--lua/nvim-lsp-installer/installers/gem.lua36
-rw-r--r--lua/nvim-lsp-installer/installers/go.lua33
-rw-r--r--lua/nvim-lsp-installer/installers/npm.lua27
-rw-r--r--lua/nvim-lsp-installer/installers/pip3.lua26
-rw-r--r--lua/nvim-lsp-installer/installers/std.lua6
-rw-r--r--lua/nvim-lsp-installer/servers/groovyls/init.lua2
-rw-r--r--lua/nvim-lsp-installer/servers/texlab/init.lua5
7 files changed, 88 insertions, 47 deletions
diff --git a/lua/nvim-lsp-installer/installers/gem.lua b/lua/nvim-lsp-installer/installers/gem.lua
index 6cd56547..17f53620 100644
--- a/lua/nvim-lsp-installer/installers/gem.lua
+++ b/lua/nvim-lsp-installer/installers/gem.lua
@@ -1,5 +1,7 @@
local path = require "nvim-lsp-installer.path"
local process = require "nvim-lsp-installer.process"
+local installers = require "nvim-lsp-installer.installers"
+local std = require "nvim-lsp-installer.installers.std"
local platform = require "nvim-lsp-installer.platform"
local M = {}
@@ -7,20 +9,26 @@ local M = {}
local gem = platform.is_win and "gem.cmd" or "gem"
function M.packages(packages)
- return function(server, callback, context)
- process.spawn(gem, {
- args = {
- "install",
- "--no-user-install",
- "--install-dir=.",
- "--bindir=bin",
- "--no-document",
- table.concat(packages, " "),
- },
- cwd = server.root_dir,
- stdio_sink = context.stdio_sink,
- }, callback)
- end
+ return installers.pipe {
+ std.ensure_executables {
+ { "ruby", "ruby was not found in path, refer to https://wiki.openstack.org/wiki/RubyGems." },
+ { "gem", "gem was not found in path, refer to https://wiki.openstack.org/wiki/RubyGems." },
+ },
+ function(server, callback, context)
+ process.spawn(gem, {
+ args = {
+ "install",
+ "--no-user-install",
+ "--install-dir=.",
+ "--bindir=bin",
+ "--no-document",
+ table.concat(packages, " "),
+ },
+ cwd = server.root_dir,
+ stdio_sink = context.stdio_sink,
+ }, callback)
+ end,
+ }
end
function M.executable(root_dir, executable)
diff --git a/lua/nvim-lsp-installer/installers/go.lua b/lua/nvim-lsp-installer/installers/go.lua
index 61e29383..aa2eeaba 100644
--- a/lua/nvim-lsp-installer/installers/go.lua
+++ b/lua/nvim-lsp-installer/installers/go.lua
@@ -1,25 +1,30 @@
local path = require "nvim-lsp-installer.path"
+local std = require "nvim-lsp-installer.installers.std"
+local installers = require "nvim-lsp-installer.installers"
local process = require "nvim-lsp-installer.process"
local M = {}
function M.packages(packages)
- return function(server, callback, context)
- local c = process.chain {
- env = process.graft_env {
- GO111MODULE = "on",
- GOBIN = server.root_dir,
- GOPATH = server.root_dir,
- },
- cwd = server.root_dir,
- stdio_sink = context.stdio_sink,
- }
+ return installers.pipe {
+ std.ensure_executables { { "go", "go was not found in path, refer to https://golang.org/doc/install." } },
+ function(server, callback, context)
+ local c = process.chain {
+ env = process.graft_env {
+ GO111MODULE = "on",
+ GOBIN = server.root_dir,
+ GOPATH = server.root_dir,
+ },
+ cwd = server.root_dir,
+ stdio_sink = context.stdio_sink,
+ }
- c.run("go", vim.list_extend({ "get", "-v" }, packages))
- c.run("go", { "clean", "-modcache" })
+ c.run("go", vim.list_extend({ "get", "-v" }, packages))
+ c.run("go", { "clean", "-modcache" })
- c.spawn(callback)
- end
+ c.spawn(callback)
+ end,
+ }
end
function M.executable(root_dir, executable)
diff --git a/lua/nvim-lsp-installer/installers/npm.lua b/lua/nvim-lsp-installer/installers/npm.lua
index 4900fba1..0988c82a 100644
--- a/lua/nvim-lsp-installer/installers/npm.lua
+++ b/lua/nvim-lsp-installer/installers/npm.lua
@@ -1,4 +1,6 @@
local path = require "nvim-lsp-installer.path"
+local installers = require "nvim-lsp-installer.installers"
+local std = require "nvim-lsp-installer.installers.std"
local platform = require "nvim-lsp-installer.platform"
local process = require "nvim-lsp-installer.process"
@@ -6,34 +8,47 @@ local M = {}
local npm = platform.is_win and "npm.cmd" or "npm"
+local function ensure_npm(installer)
+ return installers.pipe {
+ std.ensure_executables {
+ { "node", "node was not found in path. Refer to https://nodejs.org/en/." },
+ {
+ "npm",
+ "npm was not found in path. Refer to https://docs.npmjs.com/downloading-and-installing-node-js-and-npm.",
+ },
+ },
+ installer,
+ }
+end
+
function M.packages(packages)
- return function(server, callback, context)
+ return ensure_npm(function(server, callback, context)
process.spawn(npm, {
args = vim.list_extend({ "install" }, packages),
cwd = server.root_dir,
stdio_sink = context.stdio_sink,
}, callback)
- end
+ end)
end
function M.install(production)
- return function(server, callback, context)
+ return ensure_npm(function(server, callback, context)
process.spawn(npm, {
args = production and { "install", "--production" } or { "install" },
cwd = server.root_dir,
stdio_sink = context.stdio_sink,
}, callback)
- end
+ end)
end
function M.run(script)
- return function(server, callback, context)
+ return ensure_npm(function(server, callback, context)
process.spawn(npm, {
args = { "run", script },
cwd = server.root_dir,
stdio_sink = context.stdio_sink,
}, callback)
- end
+ end)
end
function M.executable(root_dir, executable)
diff --git a/lua/nvim-lsp-installer/installers/pip3.lua b/lua/nvim-lsp-installer/installers/pip3.lua
index 277e0321..cb0af84b 100644
--- a/lua/nvim-lsp-installer/installers/pip3.lua
+++ b/lua/nvim-lsp-installer/installers/pip3.lua
@@ -1,4 +1,6 @@
local path = require "nvim-lsp-installer.path"
+local installers = require "nvim-lsp-installer.installers"
+local std = require "nvim-lsp-installer.installers.std"
local platform = require "nvim-lsp-installer.platform"
local process = require "nvim-lsp-installer.process"
@@ -7,17 +9,23 @@ local M = {}
local REL_INSTALL_DIR = "venv"
function M.packages(packages)
- return function(server, callback, context)
- local c = process.chain {
- cwd = server.root_dir,
- stdio_sink = context.stdio_sink,
- }
+ return installers.pipe {
+ std.ensure_executables {
+ { "python3", "python3 was not found in path. Refer to https://www.python.org/downloads/." },
+ { "pip3", "pip3 was not found in path." },
+ },
+ function(server, callback, context)
+ local c = process.chain {
+ cwd = server.root_dir,
+ stdio_sink = context.stdio_sink,
+ }
- c.run("python3", { "-m", "venv", REL_INSTALL_DIR })
- c.run(M.executable(server.root_dir, "pip3"), vim.list_extend({ "install", "-U" }, packages))
+ c.run("python3", { "-m", "venv", REL_INSTALL_DIR })
+ c.run(M.executable(server.root_dir, "pip3"), vim.list_extend({ "install", "-U" }, packages))
- c.spawn(callback)
- end
+ c.spawn(callback)
+ end,
+ }
end
function M.executable(root_dir, executable)
diff --git a/lua/nvim-lsp-installer/installers/std.lua b/lua/nvim-lsp-installer/installers/std.lua
index e9f90435..f65992df 100644
--- a/lua/nvim-lsp-installer/installers/std.lua
+++ b/lua/nvim-lsp-installer/installers/std.lua
@@ -118,9 +118,11 @@ end
function M.ensure_executables(executables)
return vim.schedule_wrap(function(_, callback, context)
for i = 1, #executables do
- local executable = executables[i]
+ local entry = executables[i]
+ local executable = entry[1]
+ local error_msg = entry[2]
if vim.fn.executable(executable) ~= 1 then
- context.stdio_sink.stderr(("Missing required %q executable."):format(executable))
+ context.stdio_sink.stderr(error_msg)
callback(false)
return
end
diff --git a/lua/nvim-lsp-installer/servers/groovyls/init.lua b/lua/nvim-lsp-installer/servers/groovyls/init.lua
index 1b492c4d..cf5a3d7d 100644
--- a/lua/nvim-lsp-installer/servers/groovyls/init.lua
+++ b/lua/nvim-lsp-installer/servers/groovyls/init.lua
@@ -8,7 +8,7 @@ return server.Server:new {
name = "groovyls",
root_dir = root_dir,
installer = {
- std.ensure_executables { "javac" },
+ std.ensure_executables { { "javac", "javac was not found in path." } },
std.git_clone "https://github.com/GroovyLanguageServer/groovy-language-server",
std.gradlew {
args = { "build" },
diff --git a/lua/nvim-lsp-installer/servers/texlab/init.lua b/lua/nvim-lsp-installer/servers/texlab/init.lua
index a28b4273..6415986f 100644
--- a/lua/nvim-lsp-installer/servers/texlab/init.lua
+++ b/lua/nvim-lsp-installer/servers/texlab/init.lua
@@ -18,7 +18,10 @@ return server.Server:new {
name = "texlab",
root_dir = root_dir,
installer = {
- std.ensure_executables { "pdflatex" },
+ std.ensure_executables {
+ { "pdflatex" },
+ "A TeX distribution is not installed. Refer to https://www.latex-project.org/get/.",
+ },
std.untargz_remote(("https://github.com/latex-lsp/texlab/releases/download/%s/%s"):format(VERSION, target)),
},
default_options = {