aboutsummaryrefslogtreecommitdiffstats
path: root/lua
diff options
context:
space:
mode:
Diffstat (limited to 'lua')
-rw-r--r--lua/nvim-lsp-installer.lua5
-rw-r--r--lua/nvim-lsp-installer/dispatcher.lua8
-rw-r--r--lua/nvim-lsp-installer/installers/shell.lua4
-rw-r--r--lua/nvim-lsp-installer/installers/zx.lua10
-rw-r--r--lua/nvim-lsp-installer/server.lua4
-rw-r--r--lua/nvim-lsp-installer/servers/eslintls/README.md4
-rw-r--r--lua/nvim-lsp-installer/ui/display.lua6
-rw-r--r--lua/nvim-lsp-installer/ui/init.lua4
8 files changed, 24 insertions, 21 deletions
diff --git a/lua/nvim-lsp-installer.lua b/lua/nvim-lsp-installer.lua
index 5b3e7cff..bc1c5bad 100644
--- a/lua/nvim-lsp-installer.lua
+++ b/lua/nvim-lsp-installer.lua
@@ -45,8 +45,9 @@ end
function M.on_server_ready(cb)
dispatcher.register_server_ready_callback(cb)
vim.schedule(function()
- for _, server in pairs(servers.get_installed_servers()) do
- dispatcher.dispatch_server_ready(server)
+ local installed_servers = servers.get_installed_servers()
+ for i = 1, #installed_servers do
+ dispatcher.dispatch_server_ready(installed_servers[i])
end
end)
end
diff --git a/lua/nvim-lsp-installer/dispatcher.lua b/lua/nvim-lsp-installer/dispatcher.lua
index 00f38de9..4bf0c0e9 100644
--- a/lua/nvim-lsp-installer/dispatcher.lua
+++ b/lua/nvim-lsp-installer/dispatcher.lua
@@ -2,11 +2,11 @@ local M = {}
local registered_callbacks = {}
-M.dispatch_server_ready = vim.schedule_wrap(function(server)
- for _, callback in pairs(registered_callbacks) do
- callback(server)
+M.dispatch_server_ready = function(server)
+ for i = 1, #registered_callbacks do
+ registered_callbacks[i](server)
end
-end)
+end
local idx = 0
function M.register_server_ready_callback(callback)
diff --git a/lua/nvim-lsp-installer/installers/shell.lua b/lua/nvim-lsp-installer/installers/shell.lua
index 2ba84305..dbf0c17a 100644
--- a/lua/nvim-lsp-installer/installers/shell.lua
+++ b/lua/nvim-lsp-installer/installers/shell.lua
@@ -4,10 +4,10 @@ local process = require "nvim-lsp-installer.process"
local M = {}
local function shell(opts)
- return function(server, callback, installer_opts)
+ return function(server, callback, context)
local _, stdio = process.spawn(opts.shell, {
cwd = server.root_dir,
- stdio_sink = installer_opts.stdio_sink,
+ stdio_sink = context.stdio_sink,
env = process.graft_env(opts.env or {}),
}, callback)
diff --git a/lua/nvim-lsp-installer/installers/zx.lua b/lua/nvim-lsp-installer/installers/zx.lua
index 7bebdc33..04be94c6 100644
--- a/lua/nvim-lsp-installer/installers/zx.lua
+++ b/lua/nvim-lsp-installer/installers/zx.lua
@@ -15,7 +15,7 @@ local has_installed_zx = false
local function zx_installer(force)
force = force or false -- be careful with boolean logic if flipping this
- return function(_, callback, opts)
+ return function(_, callback, context)
if has_installed_zx and not force then
callback(true, "zx already installed")
return
@@ -30,7 +30,7 @@ local function zx_installer(force)
local npm_command = is_zx_already_installed and "update" or "install"
if not is_zx_already_installed then
- opts.stdio_sink.stdout(("Preparing for installation… (npm %s zx)"):format(npm_command))
+ context.stdio_sink.stdout(("Preparing for installation… (npm %s zx)"):format(npm_command))
end
fs.mkdirp(INSTALL_DIR)
@@ -39,19 +39,19 @@ local function zx_installer(force)
local handle, pid = process.spawn(platform.is_win and "npm.cmd" or "npm", {
args = { npm_command, "zx@1" },
cwd = INSTALL_DIR,
- stdio_sink = opts.stdio_sink,
+ stdio_sink = context.stdio_sink,
}, function(success)
if success then
has_installed_zx = true
callback(true)
else
- opts.stdio_sink.stderr "Failed to install zx."
+ context.stdio_sink.stderr "Failed to install zx."
callback(false)
end
end)
if handle == nil then
- opts.stdio_sink.stderr(("Failed to install/update zx. %s"):format(pid))
+ context.stdio_sink.stderr(("Failed to install/update zx. %s"):format(pid))
callback(false)
end
end
diff --git a/lua/nvim-lsp-installer/server.lua b/lua/nvim-lsp-installer/server.lua
index a2bc4b5d..ccad4c77 100644
--- a/lua/nvim-lsp-installer/server.lua
+++ b/lua/nvim-lsp-installer/server.lua
@@ -87,7 +87,9 @@ function M.Server:install_attached(opts, callback)
if not success then
pcall(self.uninstall, self)
else
- dispatcher.dispatch_server_ready(self)
+ vim.schedule(function()
+ dispatcher.dispatch_server_ready(self)
+ end)
end
callback(success)
end, opts)
diff --git a/lua/nvim-lsp-installer/servers/eslintls/README.md b/lua/nvim-lsp-installer/servers/eslintls/README.md
index 52f09f0b..2a5307df 100644
--- a/lua/nvim-lsp-installer/servers/eslintls/README.md
+++ b/lua/nvim-lsp-installer/servers/eslintls/README.md
@@ -10,7 +10,7 @@ local lsp_installer = require "nvim-lsp-installer"
function common_on_attach(client, bufnr) ... end
-for _, server in pairs(installed_servers) do
+lsp_installer.on_server_ready(function (server)
local opts = {
on_attach = common_on_attach,
}
@@ -28,7 +28,7 @@ for _, server in pairs(installed_servers) do
end
server:setup(opts)
-end
+end)
```
This will make `eslintls` respond to formatting requests, for example when triggered through:
diff --git a/lua/nvim-lsp-installer/ui/display.lua b/lua/nvim-lsp-installer/ui/display.lua
index 1027afaa..b47f0455 100644
--- a/lua/nvim-lsp-installer/ui/display.lua
+++ b/lua/nvim-lsp-installer/ui/display.lua
@@ -97,14 +97,14 @@ local function render_node(context, node, _render_context, _output)
output.lines[#output.lines + 1] = full_line
end
- elseif node.type == Ui.NodeType.NODE or node.type == Ui.NodeType.STYLE_BLOCK then
- if node.type == Ui.NodeType.STYLE_BLOCK then
+ elseif node.type == Ui.NodeType.NODE or node.type == Ui.NodeType.CASCADING_STYLE then
+ if node.type == Ui.NodeType.CASCADING_STYLE then
render_context.applied_block_styles[#render_context.applied_block_styles + 1] = node.styles
end
for i = 1, #node.children do
render_node(context, node.children[i], render_context, output)
end
- if node.type == Ui.NodeType.STYLE_BLOCK then
+ if node.type == Ui.NodeType.CASCADING_STYLE then
render_context.applied_block_styles[#render_context.applied_block_styles] = nil
end
end
diff --git a/lua/nvim-lsp-installer/ui/init.lua b/lua/nvim-lsp-installer/ui/init.lua
index 3b8d830a..b56dc440 100644
--- a/lua/nvim-lsp-installer/ui/init.lua
+++ b/lua/nvim-lsp-installer/ui/init.lua
@@ -3,7 +3,7 @@ local M = {}
M.NodeType = Data.enum {
"NODE",
- "STYLE_BLOCK",
+ "CASCADING_STYLE",
"VIRTUAL_TEXT",
"HL_TEXT",
}
@@ -39,7 +39,7 @@ M.CascadingStyle = Data.enum {
function M.CascadingStyleNode(styles, children)
return {
- type = M.NodeType.STYLE_BLOCK,
+ type = M.NodeType.CASCADING_STYLE,
styles = styles,
children = children,
}