aboutsummaryrefslogtreecommitdiffstats
path: root/lua/nvim-lsp-installer/installers/shell.lua
blob: 7ffe007af75e6c1cdb798d187ceabe3570ca1e6f (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
local M = {}

local default_opts = {
    prefix = "set -euo pipefail;"
}

function M.raw(raw_script, opts)
    opts = opts or {}
    return function (server, callback)
        local shell = vim.o.shell
        vim.o.shell = "/bin/bash"
        vim.cmd [[new]]
        vim.fn.termopen(
            opts.prefix or default_opts.prefix .. raw_script,
            {
                cwd = server._root_dir,
                on_exit = function (_, exit_code)
                    if exit_code ~= 0 then
                        callback(false, ("Exit code was non-successful: %d"):format(exit_code))
                    else
                        callback(true, nil)
                    end
                end
            }
        )
        vim.o.shell = shell
        vim.cmd([[startinsert]]) -- so that the buffer tails the term log nicely
    end
end

return M