Compare commits

...

5 commits

Author SHA1 Message Date
Danielle McLean 6cb72c1dc8
Much friendlier LspInstall with extra messages 2023-10-09 13:47:05 +11:00
Danielle McLean 623a735688
Whoops, fix tsserver install command to be a string 2023-10-09 13:44:50 +11:00
Danielle McLean d8e42c7bf3
Customise gruvbox8 settings to my liking 2023-10-09 13:38:06 +11:00
Danielle McLean 6ea9bbb645
Switch to gruvbox8 for better :terminal support 2023-10-09 12:55:50 +11:00
Danielle McLean 7535a684a9
Run :LspInstall in term_start() to get feedback 2023-10-09 12:42:59 +11:00
3 changed files with 55 additions and 36 deletions

View file

@ -20,29 +20,22 @@ if !isdirectory($XDG_CACHE_HOME .. '/vim/pack')
PackUpdate PackUpdate
endif endif
augroup transparent_term
autocmd!
autocmd ColorScheme * highlight Normal ctermbg=NONE guibg=NONE
augroup END
set background=dark
g:gruvbox_italic = 1
g:gruvbox_improved_strings = 1
g:gruvbox_improved_warnings = 1
if has('gui_running') || has('termguicolors') if has('gui_running') || has('termguicolors')
if $COLORTERM == 'truecolor' if $COLORTERM == 'truecolor'
&t_8f = "\<Esc>[38:2:%lu:%lu:%lum" &t_8f = "\<Esc>[38:2:%lu:%lu:%lum"
&t_8b = "\<Esc>[48:2:%lu:%lu:%lum" &t_8b = "\<Esc>[48:2:%lu:%lu:%lum"
endif endif
set termguicolors set termguicolors
silent! packadd gruvbox
g:airline_theme = 'gruvbox'
colorscheme gruvbox
else
colorscheme inkpot
endif endif
set background=dark
g:gruvbox_transp_bg = 1
g:gruvbox_italicize_strings = 0
g:gruvbox_filetype_hi_groups = 1
g:gruvbox_plugin_hi_groups = 1
g:airline_theme = 'gruvbox8'
colorscheme gruvbox8
inoremap jj <Esc> inoremap jj <Esc>
nnoremap <C-t> :Files<CR> nnoremap <C-t> :Files<CR>

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',
}, },
{ {
@ -30,7 +30,7 @@ const 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',
}, },
{ {
@ -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',
}, },
] ]
@ -75,27 +75,54 @@ const lspOptions = {
command! -nargs=0 -bar LspInstall Install() command! -nargs=0 -bar LspInstall Install()
def InstalledServers(): list<dict<any>>
return lspServers->deepcopy()->filter((_, server): bool => executable(server.path) == 1)
enddef
def MissingServers(): list<dict<any>>
return lspServers->deepcopy()->filter((_, server): bool => executable(server.path) == 0)
enddef
export def LazyConfigure(): void export def LazyConfigure(): void
autocmd VimEnter * ++once Configure() autocmd VimEnter * ++once Configure()
enddef enddef
export def Configure(): void export def Configure(): void
final installedServers = lspServers->deepcopy()->filter((_, server) => executable(server.path) == 1) final installedServers = InstalledServers()
if len(lspServers) != len(installedServers) if len(lspServers) != len(installedServers)
echo (len(lspServers) - len(installedServers)) "language servers are configured, but not installed. You may want to run :LspInstall." echo $'{len(lspServers) - len(installedServers)} language servers are configured, but not installed. You may want to run :LspInstall.'
endif endif
g:LspAddServer(installedServers) g:LspAddServer(installedServers)
g:LspOptionsSet(lspOptions) g:LspOptionsSet(lspOptions)
enddef enddef
export def Install(): void export def Install(): void
# TODO: running all installations in parallel doesn't work super well, const missingServers = MissingServers()
# because some package managers use an exclusive lock while they're running. if empty(missingServers)
# Plus you don't get feedback on installation progress. Perhaps use echo $"All {len(lspServers)} configured language servers are already installed."
# term_start() instead, so installs run in series and are visible on screen? return
const missing = lspServers->copy() endif
->filter((_, server) => executable(server.path) == 0)
const jobs = missing->copy() # The installScript runs every missing server's install command, regardless
->mapnew((_, server) => async#job#start(server.install, {normalize: 'raw'})) # of whether any fail in the process. The script's exit status is the number
async#job#wait(jobs) # of failed installations.
const installScript = "failed=0\n" .. missingServers->copy()
->map((_, server): string => $"\{ {server.install}; \} || failed=$((failed + 1))")
->join("\n") .. "\nexit $failed\n"
const term = term_start('sh', {exit_cb: (job: job, status: number): void => {
# If any installations failed, keep the terminal window open so we can
# troubleshoot. If they all worked fine, close the terminal and reload the
# LSP configuration.
if status == 0
execute 'bdelete' job->ch_getbufnr('out')
Configure()
endif
}})
# We prefer term_sendkeys() over sh -c because that will display each
# command in the terminal as it's being executed, making it easier to
# understand exactly what the install script is doing.
term->term_sendkeys(installScript)
enddef enddef

View file

@ -14,8 +14,7 @@ minpac#add('k-takata/minpac', {type: 'opt'})
minpac#add('tpope/vim-sensible') minpac#add('tpope/vim-sensible')
minpac#add('prabirshrestha/async.vim') minpac#add('prabirshrestha/async.vim')
minpac#add('ciaranm/inkpot', {type: 'opt', do: 'colorscheme inkpot'}) minpac#add('lifepillar/vim-gruvbox8')
minpac#add('morhetz/gruvbox', {type: 'opt'})
minpac#add('direnv/direnv.vim') minpac#add('direnv/direnv.vim')
minpac#add('editorconfig/editorconfig-vim') minpac#add('editorconfig/editorconfig-vim')