From d7b10b13d72d4bf8f7b34779ddc3514bcc26b0f2 Mon Sep 17 00:00:00 2001 From: William Boman Date: Mon, 13 Dec 2021 07:54:47 +0100 Subject: feat: allow server installation by just typing `:LspInstall` (#331) This will prompt the user which server associated with the currently opened buffer's &filetype to install. --- plugin/nvim-lsp-installer.vim | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) (limited to 'plugin') diff --git a/plugin/nvim-lsp-installer.vim b/plugin/nvim-lsp-installer.vim index e6470072..3829384c 100644 --- a/plugin/nvim-lsp-installer.vim +++ b/plugin/nvim-lsp-installer.vim @@ -19,6 +19,9 @@ function! s:LspUninstallAllCompletion(...) abort endfunction function! s:ParseArgs(args) + if len(a:args) == 0 + return { 'sync': v:false, 'servers': [] } + endif let sync = a:args[0] == "--sync" let servers = sync ? a:args[1:] : a:args return { 'sync': sync, 'servers': servers } @@ -29,9 +32,13 @@ function! s:LspInstall(args) abort if parsed_args.sync call luaeval("require'nvim-lsp-installer'.install_sync(_A)", parsed_args.servers) else - for server_name in l:parsed_args.servers - call luaeval("require'nvim-lsp-installer'.install(_A)", server_name) - endfor + if len(parsed_args.servers) == 0 + call luaeval("require'nvim-lsp-installer'.install_by_filetype(_A)", &filetype) + else + for server_name in l:parsed_args.servers + call luaeval("require'nvim-lsp-installer'.install(_A)", server_name) + endfor + endif endif endfunction @@ -63,7 +70,7 @@ function! s:LspInstallLog() abort exe 'tabnew ' .. luaeval("require'nvim-lsp-installer.log'.outfile") endfunction -command! -bar -nargs=+ -complete=custom,s:LspInstallCompletion LspInstall call s:LspInstall([]) +command! -bar -nargs=* -complete=custom,s:LspInstallCompletion LspInstall call s:LspInstall([]) command! -bar -nargs=+ -complete=custom,s:LspUninstallCompletion LspUninstall call s:LspUninstall([]) command! -bar -nargs=? -complete=custom,s:LspUninstallAllCompletion LspUninstallAll call s:LspUninstallAll([]) -- cgit v1.2.3-70-g09d2