aboutsummaryrefslogtreecommitdiff
path: root/runtime/lua/vim/lsp/handlers.lua
diff options
context:
space:
mode:
authorJustin M. Keyes <justinkz@gmail.com>2024-04-22 00:58:48 +0200
committerJustin M. Keyes <justinkz@gmail.com>2024-04-22 02:11:23 +0200
commit9912a4c81b0856200f44a38e99d38eae44cef5c9 (patch)
tree37ac1ada1267cf9172676c69c44b02dafa23402a /runtime/lua/vim/lsp/handlers.lua
parent35e38833c54565b05a0c33ba44694fc1077dce97 (diff)
downloadrneovim-9912a4c81b0856200f44a38e99d38eae44cef5c9.tar.gz
rneovim-9912a4c81b0856200f44a38e99d38eae44cef5c9.tar.bz2
rneovim-9912a4c81b0856200f44a38e99d38eae44cef5c9.zip
refactor(lua): deprecate tbl_flatten
Problem: Besides being redundant with vim.iter():flatten(), `tbl_flatten` has these problems: - Has `tbl_` prefix but only accepts lists. - Discards some results! Compare the following: - iter.flatten(): ``` vim.iter({1, { { a = 2 } }, { 3 } }):flatten():totable() ``` - tbl_flatten: ``` vim.tbl_flatten({1, { { a = 2 } }, { 3 } }) ``` Solution: Deprecate tbl_flatten. Note: iter:flatten() currently fails ("flatten() requires a list-like table") on this code from gen_lsp.lua: local anonym = vim.iter({ -- remove nil anonymous_num > 1 and '' or nil, '---@class ' .. anonymous_classname, }):flatten():totable() Should we enhance :flatten() to work for arrays?
Diffstat (limited to 'runtime/lua/vim/lsp/handlers.lua')
-rw-r--r--runtime/lua/vim/lsp/handlers.lua2
1 files changed, 1 insertions, 1 deletions
diff --git a/runtime/lua/vim/lsp/handlers.lua b/runtime/lua/vim/lsp/handlers.lua
index d6579cf4b3..4672d94105 100644
--- a/runtime/lua/vim/lsp/handlers.lua
+++ b/runtime/lua/vim/lsp/handlers.lua
@@ -12,7 +12,7 @@ local M = {}
--- Writes to error buffer.
---@param ... string Will be concatenated before being written
local function err_message(...)
- vim.notify(table.concat(vim.tbl_flatten({ ... })), vim.log.levels.ERROR)
+ vim.notify(table.concat(vim.iter({ ... }):flatten():totable()), vim.log.levels.ERROR)
api.nvim_command('redraw')
end