diff options
author | Christian Clason <c.clason@uni-graz.at> | 2023-04-14 10:39:57 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-04-14 10:39:57 +0200 |
commit | 4d04feb6629cb049cb2a13ba35f0c8d3c6b67ff4 (patch) | |
tree | 17dadca32fa46116a9c576fc651a61bc5da8ece4 /runtime/lua/vim/lsp.lua | |
parent | 72a327cad20fa2dbb214177cc48c533543d5b9e8 (diff) | |
download | rneovim-4d04feb6629cb049cb2a13ba35f0c8d3c6b67ff4.tar.gz rneovim-4d04feb6629cb049cb2a13ba35f0c8d3c6b67ff4.tar.bz2 rneovim-4d04feb6629cb049cb2a13ba35f0c8d3c6b67ff4.zip |
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.
Diffstat (limited to 'runtime/lua/vim/lsp.lua')
-rw-r--r-- | runtime/lua/vim/lsp.lua | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/runtime/lua/vim/lsp.lua b/runtime/lua/vim/lsp.lua index 3db3545786..5c78bd7580 100644 --- a/runtime/lua/vim/lsp.lua +++ b/runtime/lua/vim/lsp.lua @@ -171,7 +171,7 @@ local function for_each_buffer_client(bufnr, fn, restrict_client_ids) if restrict_client_ids and #restrict_client_ids > 0 then local filtered_client_ids = {} for client_id in pairs(client_ids) do - if vim.tbl_contains(restrict_client_ids, client_id) then + if vim.list_contains(restrict_client_ids, client_id) then filtered_client_ids[client_id] = true end end @@ -2186,7 +2186,7 @@ function lsp.formatexpr(opts) opts = opts or {} local timeout_ms = opts.timeout_ms or 500 - if vim.tbl_contains({ 'i', 'R', 'ic', 'ix' }, vim.fn.mode()) then + if vim.list_contains({ 'i', 'R', 'ic', 'ix' }, vim.fn.mode()) then -- `formatexpr` is also called when exceeding `textwidth` in insert mode -- fall back to internal formatting return 1 |