nvim-telescope / telescope-frecency.nvim

A telescope.nvim extension that offers intelligent prioritization when selecting files from your editing history.
MIT License
773 stars 37 forks source link

feat: add frecency.query() to query DB #217

Closed delphinus closed 3 months ago

delphinus commented 3 months ago

Fix #216 Fix #125 Ref #157

This adds a feature to fetch entries from DB.

local files = require("telescope").extensions.frecency.query { limit = 3 }
-- this may includes……
-- [
--   "/path/to/foo.lua",
--   "/more/path/to/bar.md",
--   "/more/and/more/path/to/foobar.txt",
-- ]

For example, you can do live-grep'ping for files that are managed by this plugin.

vim.keymap.set("n", "<Leader>tg", function()
  local frecency = require("telescope").extensions.frecency
  require("telescope.builtin").live_grep {
    -- HACK: `search_dirs` can accept files to grep nevertheless its name
    search_dirs = frecency.query {},
  }
end)