From 4d04feb6629cb049cb2a13ba35f0c8d3c6b67ff4 Mon Sep 17 00:00:00 2001 From: Christian Clason Date: Fri, 14 Apr 2023 10:39:57 +0200 Subject: feat(lua): vim.tbl_contains supports general tables and predicates (#23040) * feat(lua): vim.tbl_contains supports general tables and predicates Problem: `vim.tbl_contains` only works for list-like tables (integer keys without gaps) and primitive values (in particular, not for nested tables). Solution: Rename `vim.tbl_contains` to `vim.list_contains` and add new `vim.tbl_contains` that works for general tables and optionally allows `value` to be a predicate function that is checked for every key. --- scripts/lintcommit.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'scripts/lintcommit.lua') diff --git a/scripts/lintcommit.lua b/scripts/lintcommit.lua index f9a4631b7e..7f3dffd22c 100644 --- a/scripts/lintcommit.lua +++ b/scripts/lintcommit.lua @@ -88,7 +88,7 @@ local function validate_commit(commit_message) -- Check if type is correct local type = vim.split(before_colon, "(", {plain = true})[1] local allowed_types = {'build', 'ci', 'docs', 'feat', 'fix', 'perf', 'refactor', 'revert', 'test', 'vim-patch'} - if not vim.tbl_contains(allowed_types, type) then + if not vim.list_contains(allowed_types, type) then return string.format( [[Invalid commit type "%s". Allowed types are: %s. -- cgit v1.3-3-g829e