Skip to content

Commit

Permalink
feat(ui): message on no dupes (#65)
Browse files Browse the repository at this point in the history
  • Loading branch information
tris203 authored Jan 2, 2024
1 parent 1ced8d4 commit 31f0a7f
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 2 deletions.
7 changes: 5 additions & 2 deletions lua/hawtkeys/duplicates.lua
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,18 @@ local tsSearch = require("hawtkeys.ts")

---@class HawtkeysDuplicatesData
---@field key string
---@field file1 HawtkeysKeyMapData
---@field file2 HawtkeysKeyMapData
---@field file1 string
---@field file2 string
---
---TODO: Make this return a HawtkeysKeyMapData instead of strings

---@return HawtkeysDuplicatesData[]
function M.show_duplicates()
local allKeys = tsSearch.get_all_keymaps()
local duplicates = utils.find_duplicates(allKeys)
local resultTable = {}
for index, data in pairs(duplicates) do
---@type HawtkeysDuplicatesData
local object = {
key = index,
file1 = data[1].from_file,
Expand Down
11 changes: 11 additions & 0 deletions lua/hawtkeys/ui.lua
Original file line number Diff line number Diff line change
Expand Up @@ -339,6 +339,17 @@ M.show_dupes = function()
virt_lines = { { { l2, "Function" } } },
})
end
if #dupes == 0 then
vim.api.nvim_buf_set_lines(
ResultBuf,
0,
-1,
false,
{ "No duplicate keybindings found" }
)

vim.api.nvim_buf_add_highlight(ResultBuf, -1, "Comment", 0, 0, -1)
end
end

M.hide = function()
Expand Down

0 comments on commit 31f0a7f

Please sign in to comment.