Skip to content

Latest commit

 

History

History
115 lines (82 loc) · 2.2 KB

README.md

File metadata and controls

115 lines (82 loc) · 2.2 KB

Session.nvim

Install

Using packer.nvim

use {
  "AbaoFromCUG/session.nvim"
}

Using lazy.nvim

{
    "AbaoFromCUG/session.nvim"
}

Setup

Default configuration

---@type session.Configuration
local config = {
    enabled = true,
    silent_restore = true,  -- silent restore session, maybe cause confusion if you log in autocmd(e.g. BufWinEnter)
    hooks = {
        pre_save = {},
        extra_save = {},
        post_save = {},
        pre_restore = {},
        post_restore = {},
    },
}

require("sesion").setup(config)

Usage

Hooks

Hooks type

  • pre_save will called before save session
  • extra_save will called after save session. Hook can return vim cmd which will be called when last reopen session automatically
  • post_save will called after extra_save
  • pre_restore will called before restore session
  • post_restore will called after restore session

You can use hook ability via two methods, setup and register, they are same

Setup hooks

---@type session.Configuration
local config = {
    enabled = true,
    hooks = {
        pre_save = {
            my_pre_save = function() 
                --some code
            end
        },
        extra_save = {
            my_extra_save = function()
                return [[lua vim.notify("hello")]]
            end,
        },
        post_save = {},
        pre_restore = {},
        post_restore = {},
    },
}

require("sesion").setup(config)

Register hooks

local session = require("session")
session.register_hook("extra_save", "my_extra_save", function()
    return [[lua vim.notify("hello")]]
end)

session.register_hook("post_restore", "my_post_restore", function()
    vim.notify("world")
end)

integrate

telescope.nvim

session.nvim support integrate with telescop.nvim, use :Telescope session to list session

local telescope = require("telescope")
telescope.load_extension("session")

Acknowledges

  • auto-sesion: a powerful and rich with features session manager