Skip to content

Commit 72e75cc

Browse files
committed
revert(api): Drop util.inspect(), correct code in util aswell.
Signed-off-by: Guennadi Maximov C <[email protected]>
1 parent 34c69be commit 72e75cc

File tree

2 files changed

+10
-38
lines changed

2 files changed

+10
-38
lines changed

lua/user_api/types/user/util.lua

-1
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,5 @@ require('user_api.types.user.autocmd')
7676
---@field assoc fun()
7777
---@field displace_letter fun(c: string, direction: ('next'|'prev')?, cycle: boolean?): string
7878
---@field mv_tbl_values? fun(T: table|table<string|integer, any>, steps: integer?, direction: ('r'|'l')?): res: table<string|integer, any>
79-
---@field inspect fun(data: any): string
8079

8180
--- vim:ts=4:sts=4:sw=4:et:ai:si:sta:noci:nopi:

lua/user_api/util/init.lua

+10-37
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ local curr_buf = vim.api.nvim_get_current_buf
44
local optset = vim.api.nvim_set_option_value
55
local in_tbl = vim.tbl_contains
66

7+
local ERROR = vim.log.levels.ERROR
8+
79
---@type User.Util
810
---@diagnostic disable-next-line:missing-fields
911
local M = {}
@@ -25,7 +27,7 @@ function M.mv_tbl_values(T, steps, direction)
2527
local empty = Value.empty
2628

2729
if not is_tbl(T) then
28-
error("(user_api.util.mv_tbl_values): Input isn't a table", vim.log.levels.ERROR)
30+
error("(user_api.util.mv_tbl_values): Input isn't a table", ERROR)
2931
end
3032

3133
if empty(T) then
@@ -104,7 +106,7 @@ function M.xor(x, y)
104106
if not require('user_api.check.value').is_bool({ x, y }, true) then
105107
M.notify.notify('An argument is not of boolean type', 'error', {
106108
hide_from_history = false,
107-
timeout = 800,
109+
timeout = 850,
108110
title = '(user_api.util.xor)',
109111
})
110112
return false
@@ -402,7 +404,7 @@ function M.displace_letter(c, direction, cycle)
402404
local fields = Value.fields
403405
local is_str = Value.is_str
404406
local is_bool = Value.is_bool
405-
local mv_tbl_values = M.mv_tbl_values
407+
local mv = M.mv_tbl_values
406408

407409
direction = (is_str(direction) and in_tbl({ 'next', 'prev' }, direction)) and direction
408410
or 'next'
@@ -416,45 +418,16 @@ function M.displace_letter(c, direction, cycle)
416418
local upper = vim.deepcopy(A.upper_map)
417419

418420
if direction == 'prev' and fields(c, lower) then
419-
return mv_tbl_values(lower, 1, 'r')[c]
421+
return mv(lower, 1, 'r')[c]
420422
elseif direction == 'next' and fields(c, lower) then
421-
return mv_tbl_values(lower, 1, 'l')[c]
423+
return mv(lower, 1, 'l')[c]
422424
elseif direction == 'prev' and fields(c, upper) then
423-
return mv_tbl_values(upper, 1, 'r')[c]
425+
return mv(upper, 1, 'r')[c]
424426
elseif direction == 'next' and fields(c, upper) then
425-
return mv_tbl_values(upper, 1, 'l')[c]
426-
end
427-
428-
error('(user_api.util.displace_letter): Invalid argument `' .. c .. '`')
429-
end
430-
431-
---@param data any
432-
---@return string
433-
function M.inspect(data)
434-
local Value = require('user_api.check.value')
435-
436-
local is_nil = Value.is_nil
437-
local is_tbl = Value.is_tbl
438-
local is_str = Value.is_str
439-
local empty = Value.empty
440-
441-
if is_nil(data) then
442-
return 'nil'
443-
end
444-
445-
if is_str(data) then
446-
return data
447-
end
448-
449-
if not is_tbl(data) then
450-
return (inspect or vim.inspect)(data)
451-
end
452-
453-
if empty(data) then
454-
return '{}'
427+
return mv(upper, 1, 'l')[c]
455428
end
456429

457-
return (inspect or vim.inspect)(data)
430+
error('(user_api.util.displace_letter): Invalid argument `' .. c .. '`', ERROR)
458431
end
459432

460433
return M

0 commit comments

Comments
 (0)