Skip to content

Commit

Permalink
feat: remove alreadyMapped flag
Browse files Browse the repository at this point in the history
  • Loading branch information
tris203 committed Dec 1, 2023
1 parent 552484c commit 98c6b81
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 17 deletions.
4 changes: 1 addition & 3 deletions lua/hawtkeys/init.lua
Original file line number Diff line number Diff line change
@@ -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

26 changes: 12 additions & 14 deletions lua/hawtkeys/score.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down

0 comments on commit 98c6b81

Please sign in to comment.