From 725c3533a1c3420d9e7a261dd4f53318d9165d63 Mon Sep 17 00:00:00 2001 From: rootiest Date: Sat, 14 Sep 2024 17:26:39 -0400 Subject: [PATCH] fix: correct frecency picker invocation in dashboard and key mappings --- lua/data/dash.lua | 4 ++-- lua/data/func.lua | 13 +++++++++++++ lua/data/keys.lua | 4 +++- 3 files changed, 18 insertions(+), 3 deletions(-) diff --git a/lua/data/dash.lua b/lua/data/dash.lua index 477637d..ca32ae2 100644 --- a/lua/data/dash.lua +++ b/lua/data/dash.lua @@ -24,7 +24,7 @@ M.alpha = { -- stylua: ignore start dashboard.section.buttons.val = { ---@diagnostic disable: param-type-mismatch - dashboard.button("f", " " .. " Find file", "Telescope frecency workspace=CWD "), + dashboard.button("f", " " .. " Find file", [[lua require("data.func").frecency_picker() ]]), dashboard.button("n", " " .. " New file", [[ ene startinsert ]]), dashboard.button("r", " " .. " Recent files", LazyVim.pick("oldfiles")), dashboard.button("g", " " .. " Grep text", LazyVim.pick("live_grep")), @@ -51,7 +51,7 @@ M.alpha = { M.dashboard_nvim = { choices = { { -- Find File - action = "lua LazyVim.pick()()", + action = 'lua require("data.func".frecency_picker()()', desc = " Find File", icon = " ", key = "f", diff --git a/lua/data/func.lua b/lua/data/func.lua index 64168d3..1578c59 100644 --- a/lua/data/func.lua +++ b/lua/data/func.lua @@ -515,6 +515,19 @@ function M.dump_buffer_to_table(register) vim.fn.setreg(register, output) end +---@function Function to open the frecency picker +---@return nil +function M.frecency_picker() + -- Trigger the picker + require("telescope").extensions.frecency.frecency() + -- Remove `A` character that is added by the picker + vim.api.nvim_feedkeys( + vim.api.nvim_replace_termcodes("", true, true, true), + "n", + false + ) +end + ---@function Function to reload the user's Neovim configuration ---@return nil function M.reload_config() diff --git a/lua/data/keys.lua b/lua/data/keys.lua index c53ae20..adb00a2 100644 --- a/lua/data/keys.lua +++ b/lua/data/keys.lua @@ -415,7 +415,9 @@ M.misc = { }, { -- Telescope Frecency lhs = "", - rhs = "Telescope frecency workspace=CWD", + rhs = function() + require("data.func").frecency_picker() + end, desc = "Telescope frecency", }, { -- Exit Neovim