lua/shared: move table util funcs to vim.shared

Use `tbl_` prefix for all table-util functions. Specify in the function
docstring if it expects a list-like or map-like table.
This commit is contained in:
Justin M. Keyes
2019-05-18 16:00:06 +02:00
parent fd04877eb0
commit 9d7aaf7149
4 changed files with 44 additions and 44 deletions

View File

@@ -15,7 +15,7 @@ local dedent = global_helpers.dedent
local eq = global_helpers.eq
local ok = global_helpers.ok
local sleep = global_helpers.sleep
local table_contains = global_helpers.table_contains
local tbl_contains = global_helpers.tbl_contains
local write_file = global_helpers.write_file
local start_dir = lfs.currentdir()
@@ -165,7 +165,7 @@ local function expect_msg_seq(...)
error(cat_err(final_error,
string.format('got %d messages (ignored %d), expected %d',
#actual_seq, nr_ignored, #expected_seq)))
elseif table_contains(ignore, msg_type) then
elseif tbl_contains(ignore, msg_type) then
nr_ignored = nr_ignored + 1
else
table.insert(actual_seq, msg)
@@ -339,9 +339,9 @@ local function remove_args(args, args_rm)
end
local last = ''
for _, arg in ipairs(args) do
if table_contains(skip_following, last) then
if tbl_contains(skip_following, last) then
last = ''
elseif table_contains(args_rm, arg) then
elseif tbl_contains(args_rm, arg) then
last = arg
else
table.insert(new_args, arg)

View File

@@ -15,7 +15,7 @@ local neq = helpers.neq
local mkdir = helpers.mkdir
local rmdir = helpers.rmdir
local alter_slashes = helpers.alter_slashes
local table_contains = helpers.table_contains
local tbl_contains = helpers.tbl_contains
describe('startup defaults', function()
describe(':filetype', function()
@@ -261,7 +261,7 @@ describe('XDG-based defaults', function()
for _,v in ipairs(rtp) do
local m = string.match(v, [=[[/\]nvim[^/\]*[/\]site.*$]=])
if m and not table_contains(rv, m) then
if m and not tbl_contains(rv, m) then
table.insert(rv, m)
end
end