1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
|
local skeleton = require 'nvim_lsp/skeleton'
require 'nvim_lsp/bashls'
require 'nvim_lsp/ccls'
require 'nvim_lsp/clangd'
require 'nvim_lsp/cssls'
require 'nvim_lsp/elmls'
require 'nvim_lsp/flow'
require 'nvim_lsp/fortls'
require 'nvim_lsp/gopls'
require 'nvim_lsp/hie'
require 'nvim_lsp/leanls'
require 'nvim_lsp/pyls'
require 'nvim_lsp/rls'
require 'nvim_lsp/solargraph'
require 'nvim_lsp/sumneko_lua'
require 'nvim_lsp/texlab'
require 'nvim_lsp/tsserver'
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]
end
return setmetatable(M, mt)
-- vim:et ts=2 sw=2
|