aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichael Lingelbach <m.j.lbach@gmail.com>2019-11-29 00:07:35 -0800
committerJustin M. Keyes <justinkz@gmail.com>2019-11-29 00:07:35 -0800
commitc57ead5cd0cd5abdb1a3a862bb2ade63c6b1018d (patch)
tree86fe3da89d79f8f5c067ea96c74dd1942fe00f09
parent[docgen] Update README.md (diff)
downloadnvim-lspconfig-c57ead5cd0cd5abdb1a3a862bb2ade63c6b1018d.tar
nvim-lspconfig-c57ead5cd0cd5abdb1a3a862bb2ade63c6b1018d.tar.gz
nvim-lspconfig-c57ead5cd0cd5abdb1a3a862bb2ade63c6b1018d.tar.bz2
nvim-lspconfig-c57ead5cd0cd5abdb1a3a862bb2ade63c6b1018d.tar.lz
nvim-lspconfig-c57ead5cd0cd5abdb1a3a862bb2ade63c6b1018d.tar.xz
nvim-lspconfig-c57ead5cd0cd5abdb1a3a862bb2ade63c6b1018d.tar.zst
nvim-lspconfig-c57ead5cd0cd5abdb1a3a862bb2ade63c6b1018d.zip
pyls_ms: Microsoft Python Language Server #57
-rw-r--r--README.md33
-rw-r--r--lua/nvim_lsp.lua1
-rw-r--r--lua/nvim_lsp/pyls_ms.lua126
3 files changed, 160 insertions, 0 deletions
diff --git a/README.md b/README.md
index b690f019..8c3ad0f5 100644
--- a/README.md
+++ b/README.md
@@ -43,6 +43,7 @@ Implemented language servers:
- [hie](#hie)
- [leanls](#leanls)
- [pyls](#pyls)
+- [pyls_ms](#pyls_ms)
- [rls](#rls)
- [rust_analyzer](#rust_analyzer)
- [solargraph](#solargraph)
@@ -1436,6 +1437,38 @@ nvim_lsp#setup("pyls", {config})
settings = {}
```
+## pyls_ms
+
+https://github.com/Microsoft/python-language-server
+
+`Microsoft Language Server for Python `, a language server for Python.
+
+Requires [.NET Core](https://docs.microsoft.com/en-us/dotnet/core/tools/dotnet-install-script) to run. On Linux or macOS:
+
+```bash
+curl -L https://dot.net/v1/dotnet-install.sh | sh
+```
+
+This server accepts configuration via the `settings` key.
+
+```lua
+nvim_lsp.pyls_ms.setup({config})
+
+ Default Values:
+ cmd = { "dotnet exec /path/to/Microsoft.Python.LanguageServer.dll" }
+ filetypes = { "python" }
+ log_level = lsp.protocol.MessageType.Warning
+ root_dir = util.find_git_ancestor(fname) or vim.loop.os_homedir()
+ settings = {
+ python = {
+ analysis = {
+ errors = {};
+ info = {};
+ disabled = {};
+ };
+ }
+```
+
## rls
https://github.com/rust-lang/rls
diff --git a/lua/nvim_lsp.lua b/lua/nvim_lsp.lua
index 82c303f7..2c5a3271 100644
--- a/lua/nvim_lsp.lua
+++ b/lua/nvim_lsp.lua
@@ -11,6 +11,7 @@ require 'nvim_lsp/gopls'
require 'nvim_lsp/hie'
require 'nvim_lsp/leanls'
require 'nvim_lsp/pyls'
+require 'nvim_lsp/pyls_ms'
require 'nvim_lsp/rls'
require 'nvim_lsp/rust_analyzer'
require 'nvim_lsp/solargraph'
diff --git a/lua/nvim_lsp/pyls_ms.lua b/lua/nvim_lsp/pyls_ms.lua
new file mode 100644
index 00000000..eb352b11
--- /dev/null
+++ b/lua/nvim_lsp/pyls_ms.lua
@@ -0,0 +1,126 @@
+local skeleton = require 'nvim_lsp/skeleton'
+local util = require 'nvim_lsp/util'
+local lsp = vim.lsp
+
+local name = "pyls_ms"
+
+local function get_python_version()
+ local f = io.popen("python --version 2>&1") -- runs command
+ local l = f:read("*a") -- read output of command
+ f:close()
+ return l:match("^Python%s*(...).*%s*$")
+end
+
+local function make_installer()
+ local P = util.path.join
+ local install_dir = P{util.base_install_dir, name}
+
+ local bin = P{install_dir, "Microsoft.Python.LanguageServer.dll"}
+ local cmd = {"dotnet", "exec", bin}
+
+ local X = {}
+ function X.install()
+ local install_info = X.info()
+ if install_info.is_installed then
+ print(name, "is already installed")
+ return
+ end
+ if not (util.has_bins("curl")) then
+ error('Need "curl" to install this.')
+ return
+ end
+ if not (util.has_bins("dotnet")) then
+ error('Need ".NET Core" to install this.')
+ return
+ end
+
+ local system
+ if vim.fn.has('mac') then
+ system = 'osx'
+ elseif vim.fn.has('unix') then
+ system = 'linux'
+ elseif vim.fn.has('win32') then
+ system = 'win'
+ else
+ error('Unable to identify host operating system')
+ end
+
+ local url = string.format("https://pvsc.azureedge.net/python-language-server-stable/Python-Language-Server-%s-x64.0.4.114.nupkg", string.lower(system))
+ download_cmd = string.format('curl -fLo %s --create-dirs %s', install_info.install_dir .. "/pyls.nupkg", url)
+
+ if vim.fn.has('mac') or vim.fn.has('unix') then
+ install_cmd = "unzip " .. install_info.install_dir .. "/pyls.nupkg -d " .. install_info.install_dir
+ elseif vim.fn.has('win32') then
+ install_cmd = "Expand-Archive -Force " .. install_info.install_dir .. "/pyls.nupkg -d " .. install_info.install_dir
+ end
+
+ vim.fn.system(download_cmd)
+ vim.fn.system(install_cmd)
+ end
+ function X.info()
+ return {
+ is_installed = util.path.exists(bin);
+ install_dir = install_dir;
+ cmd = cmd;
+ }
+ end
+ function X.configure(config)
+ local install_info = X.info()
+ if install_info.is_installed then
+ config.cmd = cmd
+ end
+ end
+ return X
+end
+
+local installer = make_installer()
+
+skeleton[name] = {
+
+ default_config = {
+ filetypes = {"python"};
+ root_dir = function(fname)
+ return util.find_git_ancestor(fname) or vim.loop.os_homedir()
+ end;
+ log_level = lsp.protocol.MessageType.Warning;
+ settings = {
+ python = {
+ analysis = {
+ errors = {};
+ info = {};
+ disabled = {};
+ };
+ };
+ };
+ on_new_config = function(config)
+ installer.configure(config)
+ end;
+ init_options = {
+ interpreter =
+ {
+ properties=
+ {
+ InterpreterPath=vim.fn.exepath("python");
+ Version=get_python_version();
+ };
+ };
+ displayOptions= {};
+ analysisUpdates=true;
+ asyncStartup=true;
+ };
+ };
+ -- on_new_config = function(new_config) end;
+ -- on_attach = function(client, bufnr) end;
+ docs = {
+ description = [[
+ https://github.com/Microsoft/python-language-server
+ `python-language-server`, a language server for Python.
+ ]];
+ default_config = {
+ root_dir = "vim's starting directory";
+ };
+ };
+};
+
+skeleton[name].install = installer.install
+skeleton[name].install_info = installer.info