aboutsummaryrefslogtreecommitdiffstats
path: root/lua/nvim-lsp-installer/installers/shell.lua
diff options
context:
space:
mode:
authorWilliam Boman <william@redwill.se>2021-09-07 02:44:09 +0200
committerGitHub <noreply@github.com>2021-09-07 02:44:09 +0200
commit00294b84031711013a385f18c0fb0e8db84ebaf9 (patch)
treee45de668229c6b41643c5d1fa0fdb5beb0ff60fa /lua/nvim-lsp-installer/installers/shell.lua
parentlazily require servers for faster startup times (#77) (diff)
downloadmason-00294b84031711013a385f18c0fb0e8db84ebaf9.tar
mason-00294b84031711013a385f18c0fb0e8db84ebaf9.tar.gz
mason-00294b84031711013a385f18c0fb0e8db84ebaf9.tar.bz2
mason-00294b84031711013a385f18c0fb0e8db84ebaf9.tar.lz
mason-00294b84031711013a385f18c0fb0e8db84ebaf9.tar.xz
mason-00294b84031711013a385f18c0fb0e8db84ebaf9.tar.zst
mason-00294b84031711013a385f18c0fb0e8db84ebaf9.zip
add direct integration with libuv instead of going through termopen, also implement a UI (#79)
* add direct integration with libuv instead of going through termopen, also implement a UI * alleged free perf boosts yo that's free cycles
Diffstat (limited to 'lua/nvim-lsp-installer/installers/shell.lua')
-rw-r--r--lua/nvim-lsp-installer/installers/shell.lua38
1 files changed, 14 insertions, 24 deletions
diff --git a/lua/nvim-lsp-installer/installers/shell.lua b/lua/nvim-lsp-installer/installers/shell.lua
index 98f12103..37b5e03f 100644
--- a/lua/nvim-lsp-installer/installers/shell.lua
+++ b/lua/nvim-lsp-installer/installers/shell.lua
@@ -1,31 +1,21 @@
local installers = require "nvim-lsp-installer.installers"
+local process = require "nvim-lsp-installer.process"
local M = {}
-local function termopen(opts)
- return function(server, callback)
- local jobstart_opts = {
- cwd = server._root_dir,
- on_exit = function(_, exit_code)
- if exit_code ~= 0 then
- callback(false, ("Exit code %d"):format(exit_code))
- else
- callback(true, nil)
- end
- end,
- }
+local function shell(opts)
+ return function(server, callback, installer_opts)
+ local _, stdio = process.spawn(opts.shell, {
+ cwd = server.root_dir,
+ stdio_sink = installer_opts.stdio_sink,
+ env = process.graft_env(opts.env or {}),
+ }, callback)
- if type(opts.env) == "table" and vim.tbl_count(opts.env) > 0 then
- -- passing an empty Lua table causes E475, for whatever reason
- jobstart_opts.env = opts.env
- end
+ local stdin = stdio[1]
- local orig_shell = vim.o.shell
- vim.o.shell = opts.shell
- vim.cmd [[new]]
- vim.fn.termopen(opts.cmd, jobstart_opts)
- vim.o.shell = orig_shell
- vim.cmd [[startinsert]] -- so that we tail the term log nicely ¯\_(ツ)_/¯
+ stdin:write(opts.cmd)
+ stdin:write "\n"
+ stdin:close()
end
end
@@ -36,7 +26,7 @@ function M.bash(raw_script, opts)
}
opts = vim.tbl_deep_extend("force", default_opts, opts or {})
- return termopen {
+ return shell {
shell = "/bin/bash",
cmd = (opts.prefix or "") .. raw_script,
env = opts.env,
@@ -53,7 +43,7 @@ function M.cmd(raw_script, opts)
}
opts = vim.tbl_deep_extend("force", default_opts, opts or {})
- return termopen {
+ return shell {
shell = "cmd.exe",
cmd = raw_script,
env = opts.env,