Get automatic LSP server install working (UX kinda sucks tho)
This commit is contained in:
parent
8bd7acf409
commit
8d22d965b4
1 changed files with 16 additions and 9 deletions
|
@ -1,12 +1,12 @@
|
||||||
vim9script
|
vim9script
|
||||||
|
|
||||||
final lspServers = [
|
const lspServers = [
|
||||||
{
|
{
|
||||||
name: 'dockerfile-langserver',
|
name: 'dockerfile-langserver',
|
||||||
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 @@ final 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'],
|
||||||
},
|
},
|
||||||
|
|
||||||
{
|
{
|
||||||
|
@ -22,7 +22,7 @@ final lspServers = [
|
||||||
filetype: ['javascript', 'typescript'],
|
filetype: ['javascript', 'typescript'],
|
||||||
path: '/usr/local/bin/typescript-language-server',
|
path: '/usr/local/bin/typescript-language-server',
|
||||||
args: ['--stdio'],
|
args: ['--stdio'],
|
||||||
install: 'brew install typescript-language-server',
|
install: ['brew', 'install', 'typescript-language-server'],
|
||||||
},
|
},
|
||||||
|
|
||||||
{
|
{
|
||||||
|
@ -33,7 +33,7 @@ final lspServers = [
|
||||||
initializationOptions: {
|
initializationOptions: {
|
||||||
'language_server_configuration.auto_config': false,
|
'language_server_configuration.auto_config': false,
|
||||||
},
|
},
|
||||||
install: 'curl -Lo phpactor https://github.com/phpactor/phpactor/releases/latest/download/phpactor.phar && chmod u+x phpactor && mv phpactor ~/bin'
|
install: ['bash', '-c', 'curl -Lo phpactor https://github.com/phpactor/phpactor/releases/latest/download/phpactor.phar && chmod u+x phpactor && mv phpactor ~/bin'],
|
||||||
},
|
},
|
||||||
|
|
||||||
{
|
{
|
||||||
|
@ -41,7 +41,7 @@ final 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'],
|
||||||
},
|
},
|
||||||
|
|
||||||
{
|
{
|
||||||
|
@ -49,18 +49,25 @@ final 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'],
|
||||||
},
|
},
|
||||||
]
|
]
|
||||||
|
|
||||||
final lspOptions = {
|
const lspOptions = {
|
||||||
aleSupport: true,
|
aleSupport: true,
|
||||||
}
|
}
|
||||||
|
|
||||||
autocmd VimEnter * ++once {
|
autocmd VimEnter * ++once {
|
||||||
|
# TODO: work out a way nicer approach to automatically installing any
|
||||||
|
# missing language servers. Maybe use a command or something.
|
||||||
|
const missing = lspServers->copy()
|
||||||
|
->filter((_, server) => !executable(server.path))
|
||||||
|
const jobs = missing->copy()
|
||||||
|
->mapnew((_, server) => async#job#start(server.install, {normalize: 'raw'}))
|
||||||
|
async#job#wait(jobs)
|
||||||
# :call is required here because these functions from vim-lsp won't be
|
# :call is required here because these functions from vim-lsp won't be
|
||||||
# loaded yet when this file is parsed by Vim, so you get a "function not
|
# loaded yet when this file is parsed by Vim, so you get a "function not
|
||||||
# found" error if you try to call them the short way.
|
# found" error if you try to call them the short way.
|
||||||
call LspAddServer(lspServers)
|
call LspAddServer(lspServers->deepcopy()->filter((_, server) => executable(server.path)))
|
||||||
call LspOptionsSet(lspOptions)
|
call LspOptionsSet(lspOptions)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue