aboutsummaryrefslogtreecommitdiffstats
path: root/lua/nvim_lsp.lua
diff options
context:
space:
mode:
authorAshkan Kiani <ashkan.k.kiani@gmail.com>2019-11-15 17:26:22 -0800
committerGitHub <noreply@github.com>2019-11-15 17:26:22 -0800
commit5686a90890105e6271307e86b472f729af1cc4f8 (patch)
tree7d691ac0e7ea2feb58c5862dd52a1c8bfbef6fb4 /lua/nvim_lsp.lua
parent[docgen] Update README.md (diff)
downloadnvim-lspconfig-5686a90890105e6271307e86b472f729af1cc4f8.tar
nvim-lspconfig-5686a90890105e6271307e86b472f729af1cc4f8.tar.gz
nvim-lspconfig-5686a90890105e6271307e86b472f729af1cc4f8.tar.bz2
nvim-lspconfig-5686a90890105e6271307e86b472f729af1cc4f8.tar.lz
nvim-lspconfig-5686a90890105e6271307e86b472f729af1cc4f8.tar.xz
nvim-lspconfig-5686a90890105e6271307e86b472f729af1cc4f8.tar.zst
nvim-lspconfig-5686a90890105e6271307e86b472f729af1cc4f8.zip
Redo installation. (#17)
* Redo installation. Servers which want to be auto installed should specify skeleton[name].install() and it will be automatically added to the list of installable servers. - Add :LspInstall and :LspInstallInfo - Auto generate docs for servers with .install() available. - Add util.npm_installer - Refactor utf8 capabilities common config into a single function - Add contribution notes. - Also expose util.base_install_dir for other installers potentially - Fix tsserver's arguments and add javascript filetypes
Diffstat (limited to 'lua/nvim_lsp.lua')
-rw-r--r--lua/nvim_lsp.lua68
1 files changed, 67 insertions, 1 deletions
diff --git a/lua/nvim_lsp.lua b/lua/nvim_lsp.lua
index 550d56dd..629b6b0a 100644
--- a/lua/nvim_lsp.lua
+++ b/lua/nvim_lsp.lua
@@ -1,5 +1,5 @@
local skeleton = require 'nvim_lsp/skeleton'
-require 'nvim_lsp/bash'
+require 'nvim_lsp/bashls'
require 'nvim_lsp/clangd'
require 'nvim_lsp/elmls'
require 'nvim_lsp/gopls'
@@ -11,6 +11,72 @@ local M = {
util = require 'nvim_lsp/util';
}
+function M.available_servers()
+ return vim.tbl_keys(skeleton)
+end
+
+function M.installable_servers()
+ local res = {}
+ for k, v in pairs(skeleton) do
+ if v.install then table.insert(res, k) end
+ end
+ return res
+end
+
+M._root = {}
+-- Called from plugin/nvim_lsp.vim because it requires knowing that the last
+-- script in scriptnames to be executed is nvim_lsp.
+function M._root._setup()
+ local snr = tonumber(table.remove(vim.split(vim.fn.execute("scriptnames"), '\n')):match("^%s*(%d+)"))
+ local function sid(s)
+ return string.format("<SNR>%d_%s", snr, s)
+ end
+
+ M._root.commands = {
+ LspInstall = {
+ function(name)
+ local template = skeleton[name]
+ if not template then
+ return print("Invalid server name:", name)
+ end
+ if not template.install then
+ return print(name, "can't be automatically installed (yet)")
+ end
+ if template.install_info().is_installed then
+ return print(name, "is already installed")
+ end
+ template.install()
+ end;
+ "-nargs=1";
+ "-complete=custom,"..sid("complete_installable_server_names");
+ description = '`:LspInstall {name}` installs a server under stdpath("cache")/nvim_lsp/{name}';
+ };
+ LspInstallInfo = {
+ function(name)
+ if name == nil then
+ local res = {}
+ for k, v in pairs(skeleton) do
+ if v.install_info then
+ res[k] = v.install_info()
+ end
+ end
+ return print(vim.inspect(res))
+ end
+ local template = skeleton[name]
+ if not template then
+ return print("Invalid server name:", name)
+ end
+ return print(vim.inspect(template.install_info()))
+ end;
+ "-nargs=?";
+ "-complete=custom,"..sid("complete_installable_server_names");
+ description = 'Print installation info for {name} if one is specified, or all installable servers.';
+ };
+ };
+
+ M.util.create_module_commands("_root", M._root.commands)
+end
+
local mt = {}
function mt:__index(k)
return skeleton[k]