mirror of
https://github.com/neovim/neovim.git
synced 2025-12-16 03:15:39 +00:00
feat(lsp)!: remove client-server handlers from vim.lsp.handlers
- Partition the handlers in vim.lsp.handlers as: - client to server response handlers (RCS) - server to client request handlers (RSC) - server to client notification handlers (NSC) Note use string indexes instead of protocol.methods for improved typing in LuaLS (tip: use hover on RCS, RSC or NSC).
This commit is contained in:
committed by
Lewis Russell
parent
f54266dbed
commit
9b357e30fd
@@ -58,14 +58,6 @@ end
|
||||
|
||||
---@param protocol vim._gen_lsp.Protocol
|
||||
local function gen_methods(protocol)
|
||||
local output = {
|
||||
'-- Generated by gen_lsp.lua, keep at end of file.',
|
||||
'---',
|
||||
'---@enum vim.lsp.protocol.Methods',
|
||||
'---@see https://microsoft.github.io/language-server-protocol/specification/#metaModel',
|
||||
'--- LSP method names.',
|
||||
'protocol.Methods = {',
|
||||
}
|
||||
local indent = (' '):rep(2)
|
||||
|
||||
--- @class vim._gen_lsp.Request
|
||||
@@ -98,6 +90,41 @@ local function gen_methods(protocol)
|
||||
table.sort(all, function(a, b)
|
||||
return to_luaname(a.method) < to_luaname(b.method)
|
||||
end)
|
||||
|
||||
local output = {
|
||||
'-- Generated by gen_lsp.lua, keep at end of file.',
|
||||
'--- @alias vim.lsp.protocol.Method.ClientToServer',
|
||||
}
|
||||
for _, item in ipairs(all) do
|
||||
if item.method and item.messageDirection == 'clientToServer' then
|
||||
output[#output + 1] = ("--- | '%s',"):format(item.method)
|
||||
end
|
||||
end
|
||||
|
||||
vim.list_extend(output, {
|
||||
'',
|
||||
'--- @alias vim.lsp.protocol.Method.ServerToClient',
|
||||
})
|
||||
for _, item in ipairs(all) do
|
||||
if item.method and item.messageDirection == 'serverToClient' then
|
||||
output[#output + 1] = ("--- | '%s',"):format(item.method)
|
||||
end
|
||||
end
|
||||
|
||||
vim.list_extend(output, {
|
||||
'',
|
||||
'--- @alias vim.lsp.protocol.Method',
|
||||
'--- | vim.lsp.protocol.Method.ClientToServer',
|
||||
'--- | vim.lsp.protocol.Method.ServerToClient',
|
||||
'',
|
||||
'-- Generated by gen_lsp.lua, keep at end of file.',
|
||||
'---',
|
||||
'--- @enum vim.lsp.protocol.Methods',
|
||||
'--- @see https://microsoft.github.io/language-server-protocol/specification/#metaModel',
|
||||
'--- LSP method names.',
|
||||
'protocol.Methods = {',
|
||||
})
|
||||
|
||||
for _, item in ipairs(all) do
|
||||
if item.method then
|
||||
if item.documentation then
|
||||
|
||||
Reference in New Issue
Block a user