Skip to content

scottmckendry/pick-resession.nvim

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

32 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

🔭 pick-resession.nvim

A picker plugin for the wonderful resession.nvim plugin, with support for both Telescope and Snacks pickers.

image

📦 Installation & Setup

With Telescope

{
    "nvim-telescope/telescope.nvim",
    dependencies = { "scottmckendry/pick-resession.nvim" },
    config = function()
        telescope.setup({
            -- Other telescope config...
            extensions = {
                resession = {
                    prompt_title = "Find Sessions", -- telescope prompt title
                    dir = "session", -- directory where resession stores sessions
                },
            },
        })
    end,
}

With Snacks Picker

-- No setup is required when using the defaults
-- Can be added a dependency for snacks or ressession configs, if desired
{ "scottmckendry/pick-resession.nvim" },

⏪ Recommended Resession Configuration

return {
    "stevearc/resession.nvim",
    config = function()
        local resession = require("resession")
        resession.setup({})

        -- Automatically save sessions on by working directory on exit
        vim.api.nvim_create_autocmd("VimLeavePre", {
            callback = function()
                resession.save(vim.fn.getcwd(), { notify = true })
            end,
        })

        -- Automatically load sessions on startup by working directory
        vim.api.nvim_create_autocmd("VimEnter", {
            callback = function()
                -- Only load the session if nvim was started with no args
                if vim.fn.argc(-1) == 0 then
                    resession.load(vim.fn.getcwd(), { silence_errors = true })
                end
            end,
            nested = true,
        })
    end,
}

🚀 Usage

With Telescope:

:Telescope resession
require("telescope").extensions.resession.resession()

With Snacks Picker:

require("pick-resession").pick()

Key Maps:

Picker Mode Key Mapping Description
Both Normal, Insert <CR> Load the selected session
Both Normal, Insert <C-d> Delete the selected session

🎨 Customization

Telescope Configuration

extensions = {
    resession = {
        prompt_title = "Your custom prompt title",
        path_substitutions = {
            { find = "/home/username", replace = "🏠" },
        },
    },
},

Snacks Picker Configuration

require("pick-resession").setup({
    prompt_title = "Your custom prompt title",
    layout = "dropdown", -- "default", "dropdown", "ivy", "select", "vscode"
    default_icon = {
        icon = "📁",
        highlight = "Directory"
    },
    -- These are processed in order, so put more specific matches first
    path_icons = {
        { match = "/home/username/projects", icon = "🛠️", highlight = "Special" },
        { match = "/home/username", icon = "🏠", highlight = "Directory" },
    },
})

About

Telescope & Snacks pickers for resession.nvim

Topics

Resources

License

Stars

Watchers

Forks

Contributors 2

  •  
  •  

Languages