From adbb93df1246434976c1f5d5020643e3472a180b Mon Sep 17 00:00:00 2001 From: Julien Vincent Date: Mon, 11 Sep 2023 17:41:01 +0100 Subject: [PATCH] Don't use return in a loop --- lua/nvim-paredit/utils/keybindings.lua | 34 ++++++++++++-------------- 1 file changed, 16 insertions(+), 18 deletions(-) diff --git a/lua/nvim-paredit/utils/keybindings.lua b/lua/nvim-paredit/utils/keybindings.lua index f4603f5..4c2262e 100644 --- a/lua/nvim-paredit/utils/keybindings.lua +++ b/lua/nvim-paredit/utils/keybindings.lua @@ -19,27 +19,25 @@ end function M.setup_keybindings(opts) for keymap, action in pairs(opts.keys) do - if not action then - return - end + if action then + local repeatable = true + if type(action.repeatable) == "boolean" then + repeatable = action.repeatable + end - local repeatable = true - if type(action.repeatable) == "boolean" then - repeatable = action.repeatable - end + local fn = action[1] + if repeatable then + fn = M.with_repeat(fn) + end - local fn = action[1] - if repeatable then - fn = M.with_repeat(fn) + vim.keymap.set(action.mode or { "n", "x" }, keymap, fn, { + desc = action[2], + buffer = opts.buf or 0, + expr = repeatable, + remap = false, + silent = true, + }) end - - vim.keymap.set(action.mode or { "n", "x" }, keymap, fn, { - desc = action[2], - buffer = opts.buf or 0, - expr = repeatable, - remap = false, - silent = true, - }) end end