aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFernando Garcia Borges <5019902+fgborges@users.noreply.github.com>2020-01-26 11:00:40 +0900
committerJustin M. Keyes <justinkz@gmail.com>2020-01-25 18:00:40 -0800
commit896f60eaebcdd3dc0f590b7651b230e51c32c22c (patch)
tree90ab504c15266d3458f35c15171006d83d7ca880
parentyaml-language-server #88 (diff)
downloadnvim-lspconfig-896f60eaebcdd3dc0f590b7651b230e51c32c22c.tar
nvim-lspconfig-896f60eaebcdd3dc0f590b7651b230e51c32c22c.tar.gz
nvim-lspconfig-896f60eaebcdd3dc0f590b7651b230e51c32c22c.tar.bz2
nvim-lspconfig-896f60eaebcdd3dc0f590b7651b230e51c32c22c.tar.lz
nvim-lspconfig-896f60eaebcdd3dc0f590b7651b230e51c32c22c.tar.xz
nvim-lspconfig-896f60eaebcdd3dc0f590b7651b230e51c32c22c.tar.zst
nvim-lspconfig-896f60eaebcdd3dc0f590b7651b230e51c32c22c.zip
metals (75
Co-authored-by: Hirokazu Hata <h.hata.ai.t@gmail.com>
-rw-r--r--README.md61
-rw-r--r--lua/nvim_lsp.lua1
-rw-r--r--lua/nvim_lsp/metals.lua79
3 files changed, 141 insertions, 0 deletions
diff --git a/README.md b/README.md
index 01f2e986..1e2272c8 100644
--- a/README.md
+++ b/README.md
@@ -208,6 +208,7 @@ that config.
- [hie](#hie)
- [intelephense](#intelephense)
- [leanls](#leanls)
+- [metals](#metals)
- [ocamlls](#ocamlls)
- [pyls](#pyls)
- [pyls_ms](#pyls_ms)
@@ -1362,6 +1363,66 @@ require'nvim_lsp'.leanls.setup{}
settings = {}
```
+## metals
+
+https://scalameta.org/metals/
+
+Scala language server with rich IDE features.
+`metals` can be installed via `:LspInstall metals`.
+
+Can be installed in Nvim with `:LspInstall metals`
+This server accepts configuration via the `settings` key.
+<details><summary>Available settings:</summary>
+
+- **`metals.customRepositories`**: `array`
+
+ Array items: `{type = "string"}`
+
+- **`metals.gradleScript`**: `string`
+
+
+
+- **`metals.javaHome`**: `string`
+
+
+
+- **`metals.mavenScript`**: `string`
+
+
+
+- **`metals.millScript`**: `string`
+
+
+
+- **`metals.sbtScript`**: `string`
+
+
+
+- **`metals.scalafmtConfigPath`**: `string`
+
+
+
+- **`metals.serverProperties`**: `array`
+
+ Array items: `{type = "string"}`
+
+- **`metals.serverVersion`**: `string`
+
+ Default: `"0.7.6"`
+
+</details>
+
+```lua
+require'nvim_lsp'.metals.setup{}
+
+ Default Values:
+ cmd = { "metals" }
+ filetype = { "scala", "sbt" }
+ log_level = 2
+ root_dir = util.root_pattern("build.sbt")
+ settings = {}
+```
+
## ocamlls
https://github.com/ocaml-lsp/ocaml-language-server
diff --git a/lua/nvim_lsp.lua b/lua/nvim_lsp.lua
index dffdb6ae..734e1175 100644
--- a/lua/nvim_lsp.lua
+++ b/lua/nvim_lsp.lua
@@ -21,6 +21,7 @@ require 'nvim_lsp/solargraph'
require 'nvim_lsp/sumneko_lua'
require 'nvim_lsp/texlab'
require 'nvim_lsp/tsserver'
+require 'nvim_lsp/metals'
require 'nvim_lsp/vimls'
require 'nvim_lsp/ocamlls'
require 'nvim_lsp/terraformls'
diff --git a/lua/nvim_lsp/metals.lua b/lua/nvim_lsp/metals.lua
new file mode 100644
index 00000000..01432ed1
--- /dev/null
+++ b/lua/nvim_lsp/metals.lua
@@ -0,0 +1,79 @@
+local skeleton = require 'nvim_lsp/skeleton'
+local util = require 'nvim_lsp/util'
+local lsp = vim.lsp
+local server_name = "metals"
+local bin_name = "metals"
+
+local function make_installer()
+ local install_dir = util.path.join{util.base_install_dir, server_name}
+ local metals_bin = util.path.join{install_dir, bin_name}
+ local X = {}
+ function X.install()
+ local install_info = X.info()
+ if install_info.is_installed then
+ print(server_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("java")) then
+ error('Need "JDK" to install this.')
+ return
+ end
+ local coursier_bin = install_dir .. "/coursier"
+ local download_cmd = string.format("curl -fLo %s --create-dirs https://git.io/coursier", coursier_bin)
+ local chmod_cmd = string.format("chmod +x %s", coursier_bin)
+ local install_cmd = string.format("%s bootstrap --java-opt -Xss4m --java-opt -Xms100m --java-opt -Dmetals.client=coc.nvim org.scalameta:metals_2.12:latest.release -r bintray:scalacenter/releases -r sonatype:snapshots -o %s -f", coursier_bin, metals_bin)
+ vim.fn.system(download_cmd)
+ vim.fn.system(chmod_cmd)
+ vim.fn.system(install_cmd)
+ end
+ function X.info()
+ return {
+ is_installed = util.path.exists(metals_bin);
+ install_dir = install_dir;
+ cmd = { metals_bin };
+ }
+ end
+ function X.configure(config)
+ local install_info = X.info()
+ if install_info.is_installed then
+ config.cmd = install_info.cmd
+ end
+ end
+ return X
+end
+
+local installer = make_installer()
+
+skeleton[server_name] = {
+ default_config = {
+ cmd = {bin_name};
+ filetype = {"scala"};
+ root_dir = util.root_pattern("build.sbt", "build.sc", "build.gradle", "pom.xml");
+ log_level = lsp.protocol.MessageType.Warning;
+ settings = {};
+ };
+ on_new_config = function(config)
+ installer.configure(config)
+ end;
+ docs = {
+ vscode = "scalameta.metals";
+ package_json = "https://raw.githubusercontent.com/scalameta/metals-vscode/master/package.json";
+ description = [[
+https://scalameta.org/metals/
+
+Scala language server with rich IDE features.
+`metals` can be installed via `:LspInstall metals`.
+]];
+ default_config = {
+ root_dir = [[util.root_pattern("build.sbt")]];
+ };
+ };
+};
+
+skeleton[server_name].install = installer.install
+skeleton[server_name].install_info = installer.info
+-- vim:et ts=2 sw=2