Skip to content

Instantly share code, notes, and snippets.

@Cretezy
Last active May 11, 2024 05:02
Show Gist options
  • Save Cretezy/83e031596a26157597dd437d7d168f3f to your computer and use it in GitHub Desktop.
Save Cretezy/83e031596a26157597dd437d7d168f3f to your computer and use it in GitHub Desktop.
Quick recent file picker in Neovim/Telescope
return {
{
"mollerhoj/telescope-recent-files.nvim",
config = function() require("telescope").load_extension("recent-files") end,
keys = {
{
"<Tab>",
function()
require("telescope").extensions["recent-files"].recent_files({
attach_mappings = function(_, map)
-- Tab/S-Tab should navigate instead of select
map("i", "<Tab>", "move_selection_next")
map("i", "<S-Tab>", "move_selection_previous")
return true
end,
})
end,
},
},
},
};
@Cretezy
Copy link
Author

Cretezy commented May 11, 2024

Alternatively, with AstroNvim (mapping through astrocore):

return {
  {
    "mollerhoj/telescope-recent-files.nvim",
    config = function() require("telescope").load_extension("recent-files") end,
    dependencies = {
      "nvim-telescope/telescope.nvim",
      {
        "AstroNvim/astrocore",
        opts = {
          mappings = {
            n = {
              ["<Tab>"] = function()
                require("telescope").extensions["recent-files"].recent_files({
                  attach_mappings = function(_, map)
                    -- Tab/S-Tab should navigate instead of select
                    map("i", "<Tab>", "move_selection_next")
                    map("i", "<S-Tab>", "move_selection_previous")

                    return true
                  end,
                })
              end,
            },
          },
        },
      },
    },
  },
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment