Git Product home page Git Product logo

nvim-session-manager's Introduction

NVIM SESSION MANAGER

A single layer implementation.

Standalone, no dependencies.

Can be used with nvim workspace manager.

User Commands:

Name Description
SessionAdd Add session
- Uses directory name if no argument is given
SessionDel Delete session
SessionList List sessions
SessionChange[!] Change session
- Defaults to last_session if no argument is given
- If used with bang, session won't be loaded
SessionSave Save session
SessionLoad[!] Load session
- If used with bang, existing buffers won't be deleted (useful during startup)
SessionName Print current session name
SessionRename Rename current session
SessionStartEvents Start events
- Events when to save a session, default is: VimLeavePre
SessionStopEvents Stop events

Functions:

Name Description
add(strName) Adds a session
- Optional: strName = CURRENT_WORKING_DIRECTORY
del(strName) Deletes a session
- Mandatory: strName
- Returns immidiately if no argument is given
list() Lists sessions
rename(strName) Renames current session
- Mandatory: strName
change_session(strName, boolLoad) Changes session
- Optional: strName = last_session
- Optional: boolLoad = true
save() Saves current session
load(boolDelBuffers) Loads current session
- Optional: boolDelBuffers = true
start_events() Starts events
stop_events() Stops events
get_session_name(boolPrint) Returns current session name
- Optional: boolPrint = false

Installation:

Lazy.nvim

{
    "The-Plottwist/nvim-session-manager",
    branch = "stable"
}

Defaults:

defaults = {
    events = {"VimPreLeave"},

    --For more info: help sessionoptions
    save_options = { "blank", "buffers", "curdir", "help", "skiprtp", "tabpages", "winsize", "winpos" },

    session_dir = vim.fn.stdpath("state") .. path_seperator .. "sessions",
	
    default_session = "last_session"
}

Notes

-To modify: require("session-manager").setup({events = {}, ...})

-Does not load any sessions by default

-Adds an ungrouped UIEnter event seperate from User events to refresh buffers when a session is loaded before UI (Gives error on empty tabpages, please close empty tabs).

Example Usage:

--enable the plugin
require("session-manager").setup()

--check if a file argument is given at vim start
vim.cmd("let g:ARGC = argc()")

--load last_session if no file argument is given
if vim.g.ARGC == 0 then
    require("session-manager").load()
end

-No need to assign to a variable like manager = require(...) as lua stores all require calls as table values where described in the section 8.1 of Programming in Lua: "[...]it keeps a table with the names of all loaded files. If a required file is already in the table, require simply returns." (Not recommended outside of configuration files)

nvim-session-manager's People

Contributors

the-plottwist avatar

Stargazers

Yuta Katayama avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.