aboutsummaryrefslogtreecommitdiffstats
path: root/lua
diff options
context:
space:
mode:
authorMorten Paulsen <46502726+mortepau@users.noreply.github.com>2020-05-21 07:46:07 +0200
committerGitHub <noreply@github.com>2020-05-21 14:46:07 +0900
commit45563299b262993760ad5b66b29e49f4f4593402 (patch)
tree15240bfed420dd9cdbabdd16d82181018cc47996 /lua
parent[docgen] Update README.md (diff)
downloadnvim-lspconfig-45563299b262993760ad5b66b29e49f4f4593402.tar
nvim-lspconfig-45563299b262993760ad5b66b29e49f4f4593402.tar.gz
nvim-lspconfig-45563299b262993760ad5b66b29e49f4f4593402.tar.bz2
nvim-lspconfig-45563299b262993760ad5b66b29e49f4f4593402.tar.lz
nvim-lspconfig-45563299b262993760ad5b66b29e49f4f4593402.tar.xz
nvim-lspconfig-45563299b262993760ad5b66b29e49f4f4593402.tar.zst
nvim-lspconfig-45563299b262993760ad5b66b29e49f4f4593402.zip
Add configuration for elixir-ls (#243)
Diffstat (limited to 'lua')
-rw-r--r--lua/nvim_lsp/elixirls.lua110
1 files changed, 110 insertions, 0 deletions
diff --git a/lua/nvim_lsp/elixirls.lua b/lua/nvim_lsp/elixirls.lua
new file mode 100644
index 00000000..fe1d37e2
--- /dev/null
+++ b/lua/nvim_lsp/elixirls.lua
@@ -0,0 +1,110 @@
+local configs = require 'nvim_lsp/configs'
+local util = require 'nvim_lsp/util'
+
+local server_name = "elixirls"
+local bin_name = "elixir-ls"
+local cmd = "language_server"
+
+if vim.fn.has('mac') == 1 or vim.fn.has('unix') == 1 then
+ cmd = cmd..".sh"
+elseif vim.fn.has('win32') == 1 or vim.fn.has('win64') == 1 then
+ cmd = cmd..".bat"
+else
+ error("System is not supported, try to install manually.")
+ return
+end
+
+local function make_installer()
+ local P = util.path.join
+ local install_dir = P{util.base_install_dir, server_name}
+ local cmd_path = P{install_dir, bin_name, "release", cmd}
+
+ 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("elixir") and util.has_bins("erl")) then
+ error("Need elixir and erl to install this")
+ return
+ end
+
+ local script = [=[
+ set -e
+
+ # clone project
+ git clone https://github.com/elixir-lsp/elixir-ls
+ cd elixir-ls
+
+ # fetch dependencies and compile
+ mix deps.get && mix compile
+
+ # install executable
+ mix elixir_ls.release -o release
+ ]=]
+ vim.fn.mkdir(install_info.install_dir, "p")
+ util.sh(script, install_info.install_dir)
+ end
+
+ function X.info()
+ return {
+ is_installed = util.path.exists(cmd_path);
+ install_dir = install_dir;
+ cmd = { cmd_path };
+ }
+ 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()
+
+configs[server_name] = {
+ default_config = {
+ cmd = { cmd };
+ filetypes = {"elixir", "eelixir"};
+ root_dir = function(fname)
+ return util.root_pattern("mix.exs", ".git")(fname) or vim.loop.os_homedir()
+ end;
+ };
+ on_new_config = function(config)
+ installer.configure(config)
+ end;
+ docs = {
+ package_json = "https://raw.githubusercontent.com/JakeBecker/vscode-elixir-ls/master/package.json";
+ description = [[
+https://github.com/elixir-lsp/elixir-ls
+
+`elixir-ls` can be installed via `:LspInstall elixirls` or by yourself by following the instructions [here](https://github.com/elixir-lsp/elixir-ls#building-and-running).
+
+This language server does not provide a global binary, but must be installed manually. The command `:LspInstaller elixirls` makes an attempt at installing the binary by
+Fetching the elixir-ls repository from GitHub, compiling it and then installing it.
+
+```lua
+require'nvim_lsp'.elixirLS.setup{
+ -- Unix
+ cmd = { "path/to/language_server.sh" };
+ -- Windows
+ cmd = { "path/to/language_server.bat" };
+ ...
+}
+```
+]];
+ default_config = {
+ root_dir = [[root_pattern("mix.exs", ".git") or vim.loop.os_homedir()]];
+ };
+ };
+}
+
+configs[server_name].install = installer.install
+configs[server_name].install_info = installer.info
+-- vim:et ts=2 sw=2