aboutsummaryrefslogtreecommitdiff
path: root/runtime/lua/vim/lsp.lua
diff options
context:
space:
mode:
authorMaria José Solano <majosolano99@gmail.com>2024-03-02 13:11:23 -0800
committerChristian Clason <c.clason@uni-graz.at>2024-03-07 10:24:34 +0100
commite52c25b7617ac6401b080f76b0e227161dfef230 (patch)
tree5ba26232e1d7ef539ae727514f588e8515f4ff9e /runtime/lua/vim/lsp.lua
parent6525832a8c4d44a8ebabba02a5ea1ce09b389a4f (diff)
downloadrneovim-e52c25b7617ac6401b080f76b0e227161dfef230.tar.gz
rneovim-e52c25b7617ac6401b080f76b0e227161dfef230.tar.bz2
rneovim-e52c25b7617ac6401b080f76b0e227161dfef230.zip
feat(lua): deprecate vim.tbl_add_reverse_lookup
Diffstat (limited to 'runtime/lua/vim/lsp.lua')
-rw-r--r--runtime/lua/vim/lsp.lua15
1 files changed, 7 insertions, 8 deletions
diff --git a/runtime/lua/vim/lsp.lua b/runtime/lua/vim/lsp.lua
index ef5d9d7cff..d5c376ba44 100644
--- a/runtime/lua/vim/lsp.lua
+++ b/runtime/lua/vim/lsp.lua
@@ -146,9 +146,10 @@ end
local client_errors_base = table.maxn(lsp.rpc.client_errors)
local client_errors_offset = 0
-local function new_error_index()
+local function client_error(name)
client_errors_offset = client_errors_offset + 1
- return client_errors_base + client_errors_offset
+ local index = client_errors_base + client_errors_offset
+ return { [name] = index, [index] = name }
end
--- Error codes to be used with `on_error` from |vim.lsp.start_client|.
@@ -158,12 +159,10 @@ end
lsp.client_errors = tbl_extend(
'error',
lsp.rpc.client_errors,
- vim.tbl_add_reverse_lookup({
- BEFORE_INIT_CALLBACK_ERROR = new_error_index(),
- ON_INIT_CALLBACK_ERROR = new_error_index(),
- ON_ATTACH_ERROR = new_error_index(),
- ON_EXIT_CALLBACK_ERROR = new_error_index(),
- })
+ client_error('BEFORE_INIT_CALLBACK_ERROR'),
+ client_error('ON_INIT_CALLBACK_ERROR'),
+ client_error('ON_ATTACH_ERROR'),
+ client_error('ON_EXIT_CALLBACK_ERROR')
)
---@private