telescope-frecency.nvim/lua/telescope/_extensions/frecency.lua
JINNOUCHI Yasushi 87ccbae5d2
feat: call init process before telescope loading (#234)
* feat: call init process before telescope loading

Fix #231

This changes enable to load frecency without telescope's loading itself.
This is needed when you want to load telescope lazily, but want to start
registering process as soon as Neovim has started.

```lua
{
  "nvim-telescope/telescope-frecency.nvim",
  main = "frecency",
  ---@type FrecencyOpts
  opts = {
    db_safe_mode = false,
  },
},

{
  "nvim-telescope/telescope.nvim",
  -- `cmd` opts makes lazy.nvim load telescope.nvim lazily.
  cmd = { "Telescope" },
  config = function()
    local telescope = require "telescope"
    telescope.setup {
      extensions = {
        other_extension = {
          foo_bar = true,
        },
        -- Here you need no configuration opts for frecency because
        -- you've already done.
      }
    }
    -- This is still needed.
    telescope.load_extension "frecency"
  end,
},
```

* docs: add note for loading telescope.nvim lazily
2024-08-01 17:12:43 +09:00

27 lines
763 B
Lua

local frecency = require "frecency"
return require("telescope").register_extension {
exports = {
frecency = frecency.start,
complete = frecency.complete,
query = frecency.query,
},
setup = frecency.setup,
health = function()
if vim.F.npcall(require, "nvim-web-devicons") then
vim.health.ok "nvim-web-devicons installed."
else
vim.health.info "nvim-web-devicons is not installed."
end
if vim.fn.executable "rg" == 1 then
vim.health.ok "ripgrep installed."
elseif vim.fn.executable "fdfind" == 1 then
vim.health.ok "fdfind installed."
elseif vim.fn.executable "fd" == 1 then
vim.health.ok "fd installed."
else
vim.health.info "No suitable find executable found."
end
end,
}