Skip to content

Commit

Permalink
code review
Browse files Browse the repository at this point in the history
  • Loading branch information
tris203 committed Jan 7, 2024
1 parent 97eaeb1 commit 46dad22
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 41 deletions.
23 changes: 9 additions & 14 deletions lua/hawtkeys/ts.lua
Original file line number Diff line number Diff line change
Expand Up @@ -464,23 +464,18 @@ function M.get_all_keymaps()
end
end
else
local paths = vim.fn.stdpath("config")
if not paths then
local path = vim.fn.stdpath("config") --[[@as string]]
-- vim.fn.stdpath("config") returns string
-- https://neovim.io/doc/user/builtin.html#stdpath()
if not path then
return {}
end
if type(paths) == "string" then
paths = { paths }
end
for _, path in ipairs(paths) do
-- if string.match(path, "%.config") then
local files = find_files(path)
for _, file in ipairs(files) do
local file_keymaps = find_maps_in_file(file)
for _, keymap in ipairs(file_keymaps) do
table.insert(keymaps, keymap)
end
local files = find_files(path)
for _, file in ipairs(files) do
local file_keymaps = find_maps_in_file(file)
for _, keymap in ipairs(file_keymaps) do
table.insert(keymaps, keymap)
end
-- end
end
end

Expand Down
40 changes: 13 additions & 27 deletions tests/hawtkeys/ui_spec.lua
Original file line number Diff line number Diff line change
Expand Up @@ -18,18 +18,14 @@ describe("ui", function()
vim.cmd([[bufdo! bwipeout]])
require("hawtkeys").setup({})
vim.cmd([[lua require("hawtkeys.ui").show()]])
local ui = require("hawtkeys.ui")
SearchBuf, SearchWin, ResultBuf, ResultWin, Namespace, prompt_extmark =
unpack((function()
local ui = require("hawtkeys.ui")
return {
ui.SearchBuf,
ui.SearchWin,
ui.ResultBuf,
ui.ResultWin,
ui.Namespace,
ui.prompt_extmark,
}
end)())
ui.SearchBuf,
ui.SearchWin,
ui.ResultBuf,
ui.ResultWin,
ui.Namespace,
ui.prompt_extmark
end)

it("should show the search UI", function()
Expand Down Expand Up @@ -75,14 +71,9 @@ describe("ui", function()
vim.cmd([[bufdo! bwipeout]])
require("hawtkeys").setup({})
vim.cmd([[lua require("hawtkeys.ui").show_all()]])
ResultBuf, ResultWin, Namespace = unpack((function()
local ui = require("hawtkeys.ui")
return {
ui.ResultBuf,
ui.ResultWin,
ui.Namespace,
}
end)())
local ui = require("hawtkeys.ui")
ResultBuf, ResultWin, Namespace =
ui.ResultBuf, ui.ResultWin, ui.Namespace
end)

it("should show the all UI", function()
Expand All @@ -101,14 +92,9 @@ describe("ui", function()
describe("dupes", function()
before_each(function()
vim.cmd([[lua require("hawtkeys.ui").show_dupes()]])
ResultBuf, ResultWin, Namespace = unpack((function()
local ui = require("hawtkeys.ui")
return {
ui.ResultBuf,
ui.ResultWin,
ui.Namespace,
}
end)())
local ui = require("hawtkeys.ui")
ResultBuf, ResultWin, Namespace =
ui.ResultBuf, ui.ResultWin, ui.Namespace
end)

it("should show the duplicates UI", function()
Expand Down

0 comments on commit 46dad22

Please sign in to comment.