aboutsummaryrefslogtreecommitdiffstats
path: root/lua/nvim_lsp
diff options
context:
space:
mode:
authorWuilliam Lacruz <wuilliam.lacruz@pedidosya.com>2020-09-16 16:05:50 -0300
committerWuilliam Lacruz <wuilliam.lacruz@pedidosya.com>2020-09-16 16:05:50 -0300
commit68d915eac7e736c93295bc25f110ee81e1f02cc1 (patch)
treeb4cb947c248c8fab76ac2d65fca84902505683c8 /lua/nvim_lsp
parentfeat(groovyls) a little refactor (diff)
downloadnvim-lspconfig-68d915eac7e736c93295bc25f110ee81e1f02cc1.tar
nvim-lspconfig-68d915eac7e736c93295bc25f110ee81e1f02cc1.tar.gz
nvim-lspconfig-68d915eac7e736c93295bc25f110ee81e1f02cc1.tar.bz2
nvim-lspconfig-68d915eac7e736c93295bc25f110ee81e1f02cc1.tar.lz
nvim-lspconfig-68d915eac7e736c93295bc25f110ee81e1f02cc1.tar.xz
nvim-lspconfig-68d915eac7e736c93295bc25f110ee81e1f02cc1.tar.zst
nvim-lspconfig-68d915eac7e736c93295bc25f110ee81e1f02cc1.zip
feat(groovyls) now is installable
Diffstat (limited to 'lua/nvim_lsp')
-rw-r--r--lua/nvim_lsp/groovyls.lua96
1 files changed, 83 insertions, 13 deletions
diff --git a/lua/nvim_lsp/groovyls.lua b/lua/nvim_lsp/groovyls.lua
index 0f726e55..17cc731a 100644
--- a/lua/nvim_lsp/groovyls.lua
+++ b/lua/nvim_lsp/groovyls.lua
@@ -1,27 +1,97 @@
local configs = require 'nvim_lsp/configs'
local util = require 'nvim_lsp/util'
-local groovy_server_path = "~/groovyls/build/libs/groovyls-all.jar"
-configs.groovyls = {
- default_config = {
+local name = "groovyls"
- cmd = {
- "java", "-jar", groovy_server_path,
- };
- filetypes = {"groovy", "gsp"};
- root_dir = util.root_pattern("grails-app", ".git");
+local function make_installer()
+ local P = util.path.join
+ local install_dir = P{util.base_install_dir, name}
+
+ local bin = P{install_dir, "groovy-language-server/build/libs/groovy-language-server.jar"}
+ local cmd = {"java", "-jar", 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("java")) then
+ error('Need "Java 11+" to install this.')
+ return
+ end
+
+ local script = [=[
+set -e
+# clone project
+git clone https://github.com/prominic/groovy-language-server.git
+cd groovy-language-server
+
+# build
+./gradlew build
+ ]=]
+
+ vim.fn.mkdir(install_info.install_dir, "p")
+ util.sh(script, install_info.install_dir)
+ end
+ function X.info()
+ print(vim.inspect(cmd))
+ 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()
+configs[name] = {
+ default_config = {
+ cmd = cmd;
+ filetypes = {"groovy"};
+ root_dir = util.root_pattern("build.gradle", "pom.xml", "grails-app", ".git");
};
- -- on_new_config = function(new_config) end;
- -- on_attach = function(client, bufnr) end;
+ on_new_config = function(config)
+ installer.configure(config)
+ end;
docs = {
description = [[
-https://github.com/prominic/groovy-language-server
+https://github.com/sumneko/groovylstmp-language-server
+
+Lua language server. **By default, this doesn't have a `cmd` set.** This is
+because it doesn't provide a global binary. We provide an installer for Linux
+and macOS using `:LspInstall`. If you wish to install it yourself, [here is a
+guide](https://github.com/sumneko/groovylstmp-language-server/wiki/Build-and-Run-(Standalone)).
+So you should set `cmd` yourself like this.
-Groovy Language Server
+```groovylstmp
+require'nvim_lsp'.sumneko_groovylstmp.setup{
+ cmd = {"path", "to", "cmd"};
+ ...
+}
+```
+
+If you install via our installer, if you execute `:LspInstallInfo sumneko_groovylstmp`, you can know `cmd` value.
]];
default_config = {
- root_dir = [[root_pattern("grails-app", ".git")]];
+ filetypes = { "groovy" };
+ root_dir = [[root_pattern("build.gradle", "pom.xml", "grails-app", ".git")]];
};
};
}
+
+configs[name].install = installer.install
+configs[name].install_info = installer.info
-- vim:et ts=2 sw=2