Run :LspInstall in term_start() to get feedback

This commit is contained in:
Danielle McLean 2023-10-09 12:42:59 +11:00
parent 482e34699d
commit 7535a684a9
Signed by: 00dani
GPG key ID: 52C059C3B22A753E

View file

@ -6,7 +6,7 @@ const lspServers = [
filetype: 'dockerfile', filetype: 'dockerfile',
path: expand('~/.local/bin/docker-langserver'), path: expand('~/.local/bin/docker-langserver'),
args: ['--stdio'], args: ['--stdio'],
install: ['npm', 'install', '-g', 'dockerfile-language-server-nodejs'], install: 'npm install -g dockerfile-language-server-nodejs',
}, },
{ {
@ -14,7 +14,7 @@ const lspServers = [
filetype: 'lua', filetype: 'lua',
path: '/usr/local/bin/lua-language-server', path: '/usr/local/bin/lua-language-server',
args: [], args: [],
install: ['brew', 'install', 'lua-language-server'], install: 'brew install lua-language-server',
}, },
{ {
@ -22,7 +22,7 @@ const lspServers = [
filetype: 'bzl', filetype: 'bzl',
path: '/usr/local/bin/tilt', path: '/usr/local/bin/tilt',
args: ['lsp', 'start'], args: ['lsp', 'start'],
install: ['brew', 'install', 'tilt'], install: 'brew install tilt',
}, },
{ {
@ -41,7 +41,7 @@ const lspServers = [
initializationOptions: { initializationOptions: {
'language_server_configuration.auto_config': false, 'language_server_configuration.auto_config': false,
}, },
install: ['bash', '-c', 'curl -Lo phpactor https://github.com/phpactor/phpactor/releases/latest/download/phpactor.phar && chmod u+x phpactor && mv phpactor ~/bin'], install: 'curl -Lo phpactor https://github.com/phpactor/phpactor/releases/latest/download/phpactor.phar && chmod u+x phpactor && mv phpactor ~/bin',
}, },
{ {
@ -49,7 +49,7 @@ const lspServers = [
filetype: 'python', filetype: 'python',
path: '/usr/local/bin/pylsp', path: '/usr/local/bin/pylsp',
args: [], args: [],
install: ['brew', 'install', 'python-lsp-server'], install: 'brew install python-lsp-server',
}, },
{ {
@ -57,7 +57,7 @@ const lspServers = [
filetype: 'ruby', filetype: 'ruby',
path: '/usr/local/bin/solargraph', path: '/usr/local/bin/solargraph',
args: ['stdio'], args: ['stdio'],
install: ['brew', 'install', 'solargraph'], install: 'brew install solargraph',
}, },
{ {
@ -65,7 +65,7 @@ const lspServers = [
filetype: 'vim', filetype: 'vim',
path: expand('~/.local/bin/vim-language-server'), path: expand('~/.local/bin/vim-language-server'),
args: ['--stdio'], args: ['--stdio'],
install: ['npm', 'install', '-g', 'vim-language-server'], install: 'npm install -g vim-language-server',
}, },
] ]
@ -89,13 +89,11 @@ export def Configure(): void
enddef enddef
export def Install(): void export def Install(): void
# TODO: running all installations in parallel doesn't work super well, const installScript = lspServers->copy()
# because some package managers use an exclusive lock while they're running.
# Plus you don't get feedback on installation progress. Perhaps use
# term_start() instead, so installs run in series and are visible on screen?
const missing = lspServers->copy()
->filter((_, server) => executable(server.path) == 0) ->filter((_, server) => executable(server.path) == 0)
const jobs = missing->copy() ->map((_, server) => server.install)
->mapnew((_, server) => async#job#start(server.install, {normalize: 'raw'})) ->add("exit\n")
async#job#wait(jobs) ->join("\n")
term_start('sh')->term_sendkeys(installScript)
enddef enddef