diff --git a/lua/hawtkeys/ts.lua b/lua/hawtkeys/ts.lua index b4d71fa..648f42e 100644 --- a/lua/hawtkeys/ts.lua +++ b/lua/hawtkeys/ts.lua @@ -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 diff --git a/tests/hawtkeys/ui_spec.lua b/tests/hawtkeys/ui_spec.lua index f8d41b1..a3f82a8 100644 --- a/tests/hawtkeys/ui_spec.lua +++ b/tests/hawtkeys/ui_spec.lua @@ -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() @@ -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() @@ -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()