diff options
-rwxr-xr-x | installer/install-pyls-ms.sh | 34 | ||||
-rw-r--r-- | plugin/lsp_settings.vim | 9 | ||||
-rw-r--r-- | settings.json | 6 | ||||
-rw-r--r-- | settings/pyls-ms.vim | 32 |
4 files changed, 77 insertions, 4 deletions
diff --git a/installer/install-pyls-ms.sh b/installer/install-pyls-ms.sh new file mode 100755 index 0000000..f771f31 --- /dev/null +++ b/installer/install-pyls-ms.sh @@ -0,0 +1,34 @@ +#!/bin/bash + +set -e + +# REF https://github.com/neovim/nvim-lsp/blob/master/lua/nvim_lsp/pyls_ms.lua + +curl -L https://dot.net/v1/dotnet-install.sh | bash -s -- -i "./.dotnet" + +os=$(uname -s | tr "[:upper:]" "[:lower:]") +case $os in +linux) + system="linux" + ;; +darwin) + system="osx" + ;; +*) ;; +esac + +version="0.5.10" +url="https://pvsc.azureedge.net/python-language-server-stable/Python-Language-Server-${system}-x64.${version}.nupkg" + +nupkg="./pyls.nupkg" +curl -L "$url" -o "$nupkg" +unzip "$nupkg" + +cat <<EOF >pyls-ms +#!/bin/sh + +DIR=\$(cd \$(dirname \$0); pwd) +\$DIR/.dotnet/dotnet exec \$DIR/Microsoft.Python.LanguageServer.dll +EOF + +chmod +x pyls-ms diff --git a/plugin/lsp_settings.vim b/plugin/lsp_settings.vim index e9933b3..58aa100 100644 --- a/plugin/lsp_settings.vim +++ b/plugin/lsp_settings.vim @@ -169,13 +169,14 @@ function! s:vim_lsp_install_server(ft, command) abort endfunction function! s:vim_lsp_settings_suggest(ft) abort - if empty(s:vim_lsp_installer(a:ft)) + let l:entry = s:vim_lsp_installer(a:ft) + if empty(l:entry) return endif if exists(':LspInstallServer') !=# 2 - redraw + redraw! echohl Directory - echomsg 'Please do :LspInstallServer to enable Language Server' + echomsg 'Please do :LspInstallServer to enable Language Server ' . l:entry[0] echohl None command! -nargs=? -buffer -complete=customlist,lsp_settings#complete_install LspInstallServer call s:vim_lsp_install_server(&l:filetype, <q-args>) endif @@ -210,6 +211,7 @@ function! s:vim_lsp_settings() abort augroup vim_lsp_suggest autocmd! autocmd BufNewFile,BufRead * call s:vim_lsp_suggest_plugin() + autocmd VimEnter * call s:vim_lsp_load_or_suggest('_') augroup END command! -nargs=? -complete=customlist,lsp_settings#complete_uninstall LspUninstallServer call s:vim_lsp_uninstall_server(<q-args>) endfunction @@ -314,4 +316,3 @@ function! s:load_or_suggest_group_name(ft) abort endfunction call s:vim_lsp_settings() -call s:vim_lsp_load_or_suggest('_') diff --git a/settings.json b/settings.json index 3878bee..7fd1386 100644 --- a/settings.json +++ b/settings.json @@ -330,6 +330,12 @@ "requires": [ "python3" ] + }, + { + "command": "pyls-ms", + "requires": [ + "python" + ] } ], "reason": [ diff --git a/settings/pyls-ms.vim b/settings/pyls-ms.vim new file mode 100644 index 0000000..437d00e --- /dev/null +++ b/settings/pyls-ms.vim @@ -0,0 +1,32 @@ +augroup vimlsp_settings_pyls_ms + au! + LspRegisterServer { + \ 'name': 'pyls-ms', + \ 'cmd': {server_info->lsp_settings#get('pyls-ms', 'cmd', [lsp_settings#exec_path('pyls-ms')])}, + \ 'root_uri':{server_info->lsp_settings#get('pyls-ms', 'root_uri', lsp_settings#root_uri(g:lsp_settings_root_markers))}, + \ 'initialization_options': lsp_settings#get('pyls-ms', 'initialization_options', { + \ 'analysisUpdates': v:true, + \ 'asyncStartup': v:true, + \ 'displayOptions': {}, + \ 'interpreter': { + \ 'properties': { + \ 'InterpreterPath': lsp_settings#get('pyls-ms', 'python-path', {key, name->exepath('python')}), + \ 'UseDefaultDatabase': v:true, + \ 'Version': lsp_settings#get('pyls-ms', 'python-ver', {key, name->trim(matchstr(system('python -V'), '\s\zs\S\+'))}), + \ }, + \ }, + \ }), + \ 'whitelist': lsp_settings#get('pyls-ms', 'whitelist', ['python']), + \ 'blacklist': lsp_settings#get('pyls-ms', 'blacklist', []), + \ 'config': lsp_settings#get('pyls-ms', 'config', {}), + \ 'workspace_config': lsp_settings#get('pyls-ms', 'workspace_config', { + \ 'python': { + \ 'analysis': { + \ 'errors': [], + \ 'info': [], + \ 'disabled': [], + \ }, + \ }, + \ }), + \ } +augroup END |