jedrzejboczar / possession.nvim Goto Github PK
View Code? Open in Web Editor NEWFlexible session management for Neovim.
License: MIT License
Flexible session management for Neovim.
License: MIT License
When restoring session, the below error happens time to time. Not always.
E5108: Error executing lua ...ck/packer/opt/possession.nvim/lua/possession/session.lua:176: Vim(normal):E490: No fold found
stack traceback:
[C]: in function 'nvim_exec'
...ck/packer/opt/possession.nvim/lua/possession/session.lua:176: in function 'fn'
...possession.nvim/lua/telescope/_extensions/possession.lua:77: in function 'run_replace_or_original'
...k/packer/opt/telescope.nvim/lua/telescope/actions/mt.lua:65: in function 'key_func'
...ack/packer/opt/telescope.nvim/lua/telescope/mappings.lua:341: in function 'execute_keymap'
[string ":lua"]:1: in main chunk
My session options
vim.opt.sessionoptions =
{ 'buffers', 'curdir', 'folds', 'help', 'tabpages', 'globals', 'winsize', 'winpos', 'terminal' }
If there is a neovim terminal in a hidden buffer, possession will fail to save the session with the following message:
Cannot delete buffer with unsaved changes: "term://[...]"
Perhaps terminals should simply be force-killed if they are hidden and the option is set?
this has been driving me up the wall for the past 30 mins, why does my lua buffer close after a session save and why doesn't it show when I load said session. I've tried configuring it so it closes nothing and still got the same result.
https://asciinema.org/a/CeVVGybVHbj0Z1JXvoZ2JWCKE
minimal config on NVIM v0.7.0-dev+1275-g00effff56
return require('packer').startup(function()
use 'wbthomason/packer.nvim'
use {
'jedrzejboczar/possession.nvim',
requires = { 'nvim-lua/plenary.nvim' },
config = function() require('possession').setup{
silent = false,
load_silent = false,
debug = true,
plugins = {
close_windows = false,
delete_hidden_buffers = false,
nvim_tree = false,
tabby = false,
},
} end
}
end)
Hello. I used to use obsession
for my sessions management. But it is slightly slow...
May I use possession
the same way as obsession?
I normally do :Obsession
in session which I want to track and than i do nvim -S
if I want restore session for current dir and just nvim
if I doesn't.
How can I do it with possession
?
Again, the close everything except the open buffer is happening, tried the solution shown in previous threads but it's not workig, running on Arch Linux with the nvim 0.7.2
As noted in #2, it would be nice to have this kind of functionality built-in.
Currently one could use the provided API to do this in their config: list avaliable sessions and compare sessions[X].cwd
to current working directory to select the session we want.
Adding this feature to the plugin would require some configuration options like:
/dir/a/b
session with cwd /dir/a
should be used?tmux-resurrect is an amazing tmux plugin that allows your tmux sessions to be persistent after reboot. It has an amazing feature that allows you to also load your vim/nvim sessions afterwards as especified here restore-vim-sessions. Now the issue is when I restore my tmux session it attempts to automatically load all nvim sessions but for some reasons it can't. The feature requires that the corresponding session.vim are present in order to be able to load them. Hope anyone can reproduce the issue, thanks in advance. Sorry for opening the other issue
Hi! I'm trying this plugin out but got stuck immediately. I want to save the current session, but running :PossessionSave
prints the error "No session is currently open". Is that the intended behaviour? Since I don't yet have any sessions I can't open one.
This is my config:
use {
'jedrzejboczar/possession.nvim',
requires = { 'nvim-lua/plenary.nvim' },
config = function()
require('possession').setup()
end
}
Sometimes I want to switch projects (sessions) during the same Neovim instance. It could be a convenient feature to allow the user to close the current session without exiting Neovim.
Perhaps I'm not understanding exactly, but I would expect :PossessionSave
to save a session with the name of the current directory, not the root directory.
Currently, this is the only session file it will create.
When I dismiss the message, I get the following error:
Edit: After actually looking at the commands, I realize this requires an argument. However, when saving the session, all open buffers are closed. Very weird.
I was hoping this would be essentially a drop-in replacement for auto-sessions
which basically just manages the sessions for me. I don't want to have to type commands or use Telescope to load a session every time. If in the future, Possession
will just work out of the box like auto-session
I'll be happy to have another look!
This is best sessions plugin I have found (better then Persistence/Persisted or auto-session)
Cleanest and best configuration, custom session names (all other plugins just save session per working dir, no multiple sessions for single dir allowed)
One thing that may be lacking is command to auto name session after current git branch. Of course I can name session manually, but it would be nice to have this automated - maybe some option added to PossessionSave command
It could be even better if configuration option exist to auto load session on branch change
This is just idea, thanks for great plugin
Is there a way to show the current session name in a lualine section?
It seems like I would need to create a custom lualine component that returns the Possession session name as a string. It seems like I could get the session name from this function, but I'm not sure how to do that exactly. Any help would be appreciated! Thanks for a great plugin!
:PossessionSave
closes any buffer that's not in a window. To reproduce, use the following config:
-- Ignore default config and plugins
vim.opt.runtimepath:remove(vim.fn.expand('~/.config/nvim'))
vim.opt.packpath:remove(vim.fn.expand('~/.local/share/nvim/site'))
-- Append test directory
local test_dir = vim.fn.expand('~/code-other/nvim-test-config')
vim.opt.runtimepath:append(vim.fn.expand(test_dir))
vim.opt.packpath:append(vim.fn.expand(test_dir))
-- Install packer
local install_path = test_dir .. '/pack/packer/start/packer.nvim'
local install_plugins = false
if vim.fn.empty(vim.fn.glob(install_path)) > 0 then
vim.cmd('!git clone https://github.com/wbthomason/packer.nvim ' .. install_path)
vim.cmd('packadd packer.nvim')
install_plugins = true
end
local packer = require('packer')
packer.init({
package_root = test_dir .. '/pack',
compile_path = test_dir .. '/plugin/packer_compiled.lua'
})
packer.startup(function()
function Use(module)
use(require(string.format('configs.%s', module)))
end
-- Packer can manage itself
packer.use 'wbthomason/packer.nvim'
use { 'jedrzejboczar/possession.nvim',
requires = { 'nvim-lua/plenary.nvim' },
config = function()
require('possession').setup()
end
}
if install_plugins then
packer.sync()
else
-- load plugins at your earliest convenience
vim.defer_fn(function()
vim.cmd('doautocmd User LoadPlugins')
end, 1)
end
end)
> nvim -u path/to/file/above.lua foo bar baz -c ':buffers' -c ':PossessionSave test' -c ':buffers'
Here's the output of the first :buffers
:
1 %a "foo" line 0
2 "bar" line 0
3 "baz" line 0
And here's the output of the second :buffers
:
1 %a "foo" line 1
You get the same behaviour if you run :PossessionSave
manually from inside Neovim.
It closes all the buffers except the one in focus. Even after disabling all the plugin config
plugins = {
-- close_windows = {
-- hooks = { 'before_load', 'before_save' },
-- preserve_layout = true, -- or fun(win): boolean
-- match = {
-- floating = true,
-- buftype = {},
-- filetype = {
-- 'gitcommit',
-- 'alpha',
-- 'dashboard',
-- 'neo-tree',
-- 'Outline',
-- 'Tagbar',
-- 'Mundo',
-- 'MundoDiff',
-- 'toggleterm',
-- 'undotree',
-- 'qf',
-- },
-- custom = false, -- or fun(win): boolean
-- },
-- },
-- delete_hidden_buffers = false,
-- delete_hidden_buffers = {
-- hooks = {
-- -- 'before_load',
-- -- 'before_save',
-- vim.o.sessionoptions:match('buffer') and 'before_save',
-- },
-- force = false, -- or fun(buf): boolean
-- },
-- nvim_tree = false,
-- tabby = false,
-- delete_buffers = true,
},
My session option
vim.opt.sessionoptions = 'blank,buffers,curdir,folds,help,tabpages,globals,winsize,winpos,terminal'
It still closes all the buffers one by one. What I mean is if I have 12 buffers open, it will not close them all in a single save/restore command.
With every load/restore it will close 1 buffer. So after some use most of my buffers will be closed except the one in focus.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.