Giter Site home page Giter Site logo

sessions.nvim's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

sessions.nvim's Issues

Looking for a maintainer

Hi! I hope you are all doing well!

I no longer use Neovim regularly, but I really would like to keep this plugin alive. It's been really simple to maintain, but I worry about the long-term.

So I'm looking for someone willing to step in and maintain this plugin. Either

  1. Someone who is willing to fork and create the new official project or
  2. Someone who wants to co-maintain the project

I think the second is the simplest, and no one has to update their configs to point to a new repository.

If no one steps up, I will try my best to make sure this works for as long as possible. But I won't make any promises. If a future Neovim release would cause an unreasonable amount of work for me to update this plugin, I probably wouldn't update it.

Sorry if that's sad news for anyone, and I apologize if this breaks someone's workflow someday. I don't think this plugin will stop working anytime soon, but if it does... ๐Ÿ˜ฌ

Adding "User" as an autocmd event will not work

Hello @natecraddock, I know you said you don't use neovim anymore but I have a few questions and I was hoping you could please help me.

I'm using workspaces.nvim and sessions.nvim to manage my projects in neovim. So far I've had no real issues until today. This is what I'm using as a trigger to save the session.

require("sessions").setup({
	events = { "BufEnter" },
	session_filepath = vim.fn.stdpath("data") .. "/sessions",
	absolute = true
})

This works most of the time but is not the best solution. I want to save the session when a new buffer is added and when a buffer is deleted. So far I can save the session when adding buffers without any issues. The problem is when deleting the buffers, there is no actual way in neovim to know if a buffer has been deleted with an autocmd event.

This is where https://github.com/famiu/bufdelete.nvim comes in handy. It has an autocmd User event called BDeletePre and BDeletePost.

User autocommands

bufdelete.nvim triggers the following User autocommands (see :help User for more information):

BDeletePre {range_start,range_end} - Prior to deleting a buffer.
BDeletePost {range_start,range_end} - After deleting a buffer.

In both of these cases, range_start and range_end are replaced by the start and end of the buffer range, respectively.
For example, if you use require('bufdelete').bufdelete({1, 42}), the autocommand patterns will be BDeletePre {1,42} and BDeletePost {1,42}.

Now, if I add the "User" event like this:

require("sessions").setup({
	events = { "BufEnter", "User" },
	session_filepath = vim.fn.stdpath("data") .. "/sessions",
	absolute = true
})

That won't work.

If I add this code to sessions.nvim/lua/sessions/init.lua then it does work:

-- start autosaving changes to the session file
local start_autosave = function()
    -- save future changes
    local events = vim.fn.join(config.events, ",")
    local augroup = vim.api.nvim_create_augroup("sessions.nvim", {})
    vim.api.nvim_create_autocmd(
        string.format("%s", events),
        {
            group = augroup,
            pattern = "*",
            callback = write_session_file,
        }
    )
    vim.api.nvim_create_autocmd(
        string.format("%s", "User"),
        {
            group = augroup,
            pattern = "*",
            callback = write_session_file,
        }
    )

    -- save now
    write_session_file()
end

Do you know what I need to do to make it work without editing the plugin's source code? I'm a total noob when it comes to plugins or autocmds so any help is really appreciated. Thank you.

P.S. I loved your work on blender's outliner BTW ;)

Make start_autosave public

A quick rationale coming straight from my current session config. I want any new directory I open to automatically register as a session. At the moment it requires doing a manual save if a load fails:

vim.api.nvim_create_autocmd('VimEnter', {
  callback = function (data)
    local is_directory = vim.fn.isdirectory(data.file) == 1
    if not is_directory then
      return
    end

    vim.cmd.cd(data.file)

    local sessions_api = require('sessions')
    local session_found = sessions_api.load(nil, { silent = true })
    -- currently this is the way to start a new session if none was detected
    if not session_found then
      sessions_api.save()
    end

    -- other code omitted
  end,
})

If the sessions.start_autosave function was public (after a small refactoring to separate off writing session files), it would be slightly more convenient bc the user can delay the first save to an actual event like WinEnter.

On the other hand this might feel nitpicky, and I don't want to introduce new API if it feels unnecessary.

Shared directory for session file storage

Hi @natecraddock,

Thanks for creating this plugin. I'm happily using it in conjunction with workspaces and but noticed that the session file is always stored relative to the current cwd. I'd rather not pollute my workspace with neovim session information. It's not something I will commit nor will it be of interested to my fellow colleagues.

Is there a way to have sessions stored the same way as workspaces? Meaning that the 'data' + $SOMEDIR directory will be used to write session files, with filenames that match the current cwd?

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.