aboutsummaryrefslogtreecommitdiff
path: root/scripts/gen_lsp.lua
diff options
context:
space:
mode:
Diffstat (limited to 'scripts/gen_lsp.lua')
-rw-r--r--scripts/gen_lsp.lua33
1 files changed, 8 insertions, 25 deletions
diff --git a/scripts/gen_lsp.lua b/scripts/gen_lsp.lua
index 04d19f22e6..c8dcf8c018 100644
--- a/scripts/gen_lsp.lua
+++ b/scripts/gen_lsp.lua
@@ -60,9 +60,10 @@ end
local function gen_methods(protocol)
local output = {
'-- Generated by gen_lsp.lua, keep at end of file.',
- '--- LSP method names.',
'---',
+ '---@enum vim.lsp.protocol.Methods',
'---@see https://microsoft.github.io/language-server-protocol/specification/#metaModel',
+ '--- LSP method names.',
'protocol.Methods = {',
}
local indent = (' '):rep(2)
@@ -109,26 +110,8 @@ local function gen_methods(protocol)
end
end
output[#output + 1] = '}'
- output = vim.list_extend(
- output,
- vim.split(
- [[
-local function freeze(t)
- return setmetatable({}, {
- __index = t,
- __newindex = function()
- error('cannot modify immutable table')
- end,
- })
-end
-protocol.Methods = freeze(protocol.Methods)
-
-return protocol
-]],
- '\n',
- { trimempty = true }
- )
- )
+ output[#output + 1] = ''
+ output[#output + 1] = 'return protocol'
local fname = './runtime/lua/vim/lsp/protocol.lua'
local bufnr = vim.fn.bufadd(fname)
@@ -297,13 +280,13 @@ function M.gen(opt)
-- TupleType
elseif type.kind == 'tuple' then
- local tuple = '{ '
- for i, value in ipairs(type.items) do
- tuple = tuple .. '[' .. i .. ']: ' .. parse_type(value, prefix) .. ', '
+ local tuple = '['
+ for _, value in ipairs(type.items) do
+ tuple = tuple .. parse_type(value, prefix) .. ', '
end
-- remove , at the end
tuple = tuple:sub(0, -3)
- return tuple .. ' }'
+ return tuple .. ']'
end
vim.print('WARNING: Unknown type ', type)