@@ -4,6 +4,8 @@ local curr_buf = vim.api.nvim_get_current_buf
4
4
local optset = vim .api .nvim_set_option_value
5
5
local in_tbl = vim .tbl_contains
6
6
7
+ local ERROR = vim .log .levels .ERROR
8
+
7
9
--- @type User.Util
8
10
--- @diagnostic disable-next-line : missing-fields
9
11
local M = {}
@@ -25,7 +27,7 @@ function M.mv_tbl_values(T, steps, direction)
25
27
local empty = Value .empty
26
28
27
29
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 )
29
31
end
30
32
31
33
if empty (T ) then
@@ -104,7 +106,7 @@ function M.xor(x, y)
104
106
if not require (' user_api.check.value' ).is_bool ({ x , y }, true ) then
105
107
M .notify .notify (' An argument is not of boolean type' , ' error' , {
106
108
hide_from_history = false ,
107
- timeout = 800 ,
109
+ timeout = 850 ,
108
110
title = ' (user_api.util.xor)' ,
109
111
})
110
112
return false
@@ -402,7 +404,7 @@ function M.displace_letter(c, direction, cycle)
402
404
local fields = Value .fields
403
405
local is_str = Value .is_str
404
406
local is_bool = Value .is_bool
405
- local mv_tbl_values = M .mv_tbl_values
407
+ local mv = M .mv_tbl_values
406
408
407
409
direction = (is_str (direction ) and in_tbl ({ ' next' , ' prev' }, direction )) and direction
408
410
or ' next'
@@ -416,45 +418,16 @@ function M.displace_letter(c, direction, cycle)
416
418
local upper = vim .deepcopy (A .upper_map )
417
419
418
420
if direction == ' prev' and fields (c , lower ) then
419
- return mv_tbl_values (lower , 1 , ' r' )[c ]
421
+ return mv (lower , 1 , ' r' )[c ]
420
422
elseif direction == ' next' and fields (c , lower ) then
421
- return mv_tbl_values (lower , 1 , ' l' )[c ]
423
+ return mv (lower , 1 , ' l' )[c ]
422
424
elseif direction == ' prev' and fields (c , upper ) then
423
- return mv_tbl_values (upper , 1 , ' r' )[c ]
425
+ return mv (upper , 1 , ' r' )[c ]
424
426
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 ]
455
428
end
456
429
457
- return ( inspect or vim . inspect )( data )
430
+ error ( ' (user_api.util.displace_letter): Invalid argument ` ' .. c .. ' ` ' , ERROR )
458
431
end
459
432
460
433
return M
0 commit comments