From 98c6b812f38639f9d251ce9f7fc6096b08c355be Mon Sep 17 00:00:00 2001 From: tris203 Date: Fri, 1 Dec 2023 13:11:42 +0000 Subject: [PATCH] feat: remove alreadyMapped flag --- lua/hawtkeys/init.lua | 4 +--- lua/hawtkeys/score.lua | 26 ++++++++++++-------------- 2 files changed, 13 insertions(+), 17 deletions(-) diff --git a/lua/hawtkeys/init.lua b/lua/hawtkeys/init.lua index c8aa87c..38db98b 100644 --- a/lua/hawtkeys/init.lua +++ b/lua/hawtkeys/init.lua @@ -1,11 +1,9 @@ M = {} function M.setup(config) - M.excludeAlreadyMapped = config.excludeAlreadyMapped or true M.leader = config.leader or " " M.homerow = config.homerow or 2 M.powerFingers = config.powerFingers or { 2, 3, 6, 7 } M.keyboardLayout = config.keyboardLayout or "qwerty" - end +end return M - diff --git a/lua/hawtkeys/score.lua b/lua/hawtkeys/score.lua index 70d735c..095bbbb 100644 --- a/lua/hawtkeys/score.lua +++ b/lua/hawtkeys/score.lua @@ -86,23 +86,21 @@ local function process_string(str) table.sort(sortedScores, Score_sort) - if config.excludeAlreadyMapped then - local already_used_keys = vim.api.nvim_get_keymap("n") - - local find_mapping = function(maps, lhs) - for _, value in ipairs(maps) do - if value.lhs == lhs then - return value.rhs - end + local already_used_keys = vim.api.nvim_get_keymap("n") + + local find_mapping = function(maps, lhs) + for _, value in ipairs(maps) do + if value.lhs == lhs then + return value.rhs end - return false end + return false + end - for i = #sortedScores, 1, -1 do - if find_mapping(already_used_keys, config.leader .. sortedScores[i].combo) then - local mapping = find_mapping(already_used_keys, config.leader .. sortedScores[i].combo) - sortedScores[i].already_mapped = mapping - end + for i = #sortedScores, 1, -1 do + if find_mapping(already_used_keys, config.leader .. sortedScores[i].combo) then + local mapping = find_mapping(already_used_keys, config.leader .. sortedScores[i].combo) + sortedScores[i].already_mapped = mapping end end