aboutsummaryrefslogtreecommitdiffstats
path: root/lua/nvim-lsp-installer/server.lua
diff options
context:
space:
mode:
authorWilliam Boman <william@redwill.se>2021-05-17 15:16:07 +0200
committerGitHub <noreply@github.com>2021-05-17 15:16:07 +0200
commit79745b0a25ffb386918eec03ded27f7a7da1b96f (patch)
tree4d3f77e1a02b10fc1e58ae1df4f2a81dea25d561 /lua/nvim-lsp-installer/server.lua
parentremove logo.png from repo (diff)
downloadmason-79745b0a25ffb386918eec03ded27f7a7da1b96f.tar
mason-79745b0a25ffb386918eec03ded27f7a7da1b96f.tar.gz
mason-79745b0a25ffb386918eec03ded27f7a7da1b96f.tar.bz2
mason-79745b0a25ffb386918eec03ded27f7a7da1b96f.tar.lz
mason-79745b0a25ffb386918eec03ded27f7a7da1b96f.tar.xz
mason-79745b0a25ffb386918eec03ded27f7a7da1b96f.tar.zst
mason-79745b0a25ffb386918eec03ded27f7a7da1b96f.zip
s/install_cmd/installer/g (#15)
Diffstat (limited to 'lua/nvim-lsp-installer/server.lua')
-rw-r--r--lua/nvim-lsp-installer/server.lua15
1 files changed, 8 insertions, 7 deletions
diff --git a/lua/nvim-lsp-installer/server.lua b/lua/nvim-lsp-installer/server.lua
index 847e54e1..60e96851 100644
--- a/lua/nvim-lsp-installer/server.lua
+++ b/lua/nvim-lsp-installer/server.lua
@@ -103,17 +103,18 @@ M.Server.__index = M.Server
--
-- @field root_dir (string) The root directory of the installation. Most servers will make use of server.get_server_root_path() to produce its root_dir path.
--
--- @field install_cmd (string) The shell script that installs the LSP. Make sure to exit with an error code (e.g. exit 1) on failures.
--- The shell script is executed with "set -e" (exits the script on first non-successful command) by default.
+-- @field installer (function) The function that installs the LSP (see the .installers module). The function signature should be `function (server, callback)`, where
+-- `server` is the Server instance being installed, and `callback` is a function that must be called upon completion. The `callback` function
+-- has the signature `function (success, result)`, where `success` is a boolean and `result` is of any type (similar to `pcall`).
--
-- @field default_options (table) The default options to be passed to lspconfig's .setup() function. Each server should provide at least the `cmd` field.
--
--- @field pre_install_check (function) An optional function to be executed before the install_cmd. This allows ensuring that any prerequisites are fulfilled.
+-- @field pre_install_check (function) An optional function to be executed before the installer. This allows ensuring that any prerequisites are fulfilled.
-- This could for example be verifying that required build tools are installed.
function M.Server:new(opts)
return setmetatable({
name = opts.name,
- _install_cmd = opts.install_cmd,
+ _installer = opts.installer,
_root_dir = opts.root_dir,
_default_options = opts.default_options,
_pre_install_check = opts.pre_install_check,
@@ -149,9 +150,9 @@ function M.Server:install()
self:create_root_dir()
- self._install_cmd(self, function (_, exit_code)
- if exit_code ~= 0 then
- vim.api.nvim_err_writeln(("Server installation failed for %s. Exit code: %d"):format(self.name, exit_code))
+ self._installer(self, function (success, result)
+ if not success then
+ vim.api.nvim_err_writeln(("Server installation failed for %s. %s"):format(self.name, result))
pcall(self.uninstall, self)
else
print(("Successfully installed %s"):format(self.name))