Closed dathinaios closed 2 years ago
Ok, I see that this is simply a matter of using mks! ~/.dotfiles/dotvim/sessions/
(that is just where I personally keep my sessions) to save and so ~/.dotfiles/dotvim/sessions/<Session name>
to recall. Simple enough to define some mapping for this but it would be nice to have an MSSave
, MSLoad
etc. command. My instinct was to search with telescope on all commands for "session" and it would be nice to have found all that directly.
You have two ways:
lua MiniSessions.write(<session file name>)
and lua MiniSessions.read(<session file name>)
as SSave
and SLoad
versions. With this you have to supply manually session file name without any completion. Example: :lua MiniSessions.write('nvim-convig')
.lua MiniSessions.select(<action name>)
. It is using overridable vim.ui.select()
. Example: :lua MiniSessions.select('read')
.As a general principle 'mini.nvim' does not supply any Neovim commands. Each module creates a global Lua object (MiniSessions
for 'mini.sessions') which can be used with :lua MiniSessions...
.
Thank you! The .select
approach is quite elegant. I mapped it to a key and I am getting the selection window but when I hit <CR>
to action it, it throws an error:
E5108: Error executing lua ...m/site/pack/packer/start/mini.nvim/lua/mini/sessions.lua:577: (mini.sessions) There are unsaved buffers: 44.
stack traceback:
[C]: in function 'error'
...m/site/pack/packer/start/mini.nvim/lua/mini/sessions.lua:577: in function 'error'
...m/site/pack/packer/start/mini.nvim/lua/mini/sessions.lua:182: in function <...m/site/pack/packer/start/mini.nvim/lua/mini/sessions.lua:154>
...m/site/pack/packer/start/mini.nvim/lua/mini/sessions.lua:371: in function 'on_choice'
...e-ui-select.nvim/lua/telescope/_extensions/ui-select.lua:122: in function 'run_replace_or_original'
...packer/start/telescope.nvim/lua/telescope/actions/mt.lua:65: in function 'key_func'
...k/packer/start/telescope.nvim/lua/telescope/mappings.lua:242: in function 'execute_keymap'
[string ":lua"]:1: in main chunk
My mapping is simply:
nmap <Leader>:sl :lua MiniSessions.select('read')<CR>
nmap <Leader>:ss :lua MiniSessions.select('write')<CR>
nmap <Leader>:sd :lua MiniSessions.select('delete')<CR>
I do have a workaround so no big deal. Here it is for reference:
nmap <Leader>:ss :mks! ~/.dotfiles/dotvim/sessions/
nmap <Leader>:sl :so ~/.dotfiles/dotvim/sessions/
nmap <Leader>:sd :!rm ~/.dotfiles/dotvim/sessions/
and then I just hit <TAB>
.
Well, error message says it all. You have unsaved buffer number 44. By default, MiniSessions.read()
doesn't work if there is at least one unsaved buffer. That is something 'vim-startify' does, if I remember correctly. To ignore that, set force
option to true
: either in config.force.read
inside setup()
or as extra argument to select()
.
Indeed, but I don't have any unsaved buffers. I use auto-save + unlimited undo so that never happens. I did double check though just in case though and the error persists.
That is very strange. I can reproduce this issue only if there is unsaved buffer. How did you check for unsaved buffers? I recommend using :bmodified!
: in case of no modified buffers it gives a E84: No modified buffer found
.
If indeed no unsaved buffers, I would be grateful if you come up with reproducible example for this and create an issue.
Yes, it does return E84: No modified buffer found
. I will create an issue though not sure what a reproducible example would be. All I am doing is trying to use lua MiniSessions.select('read')
and lua MiniSessions.select('write')
.
I created issue #71. Seems to be related to Telescope
.
Contributing guidelines
Module(s)
mini.sessions
Description
Coming from
Startify
I am used to saving and loading sessions using the commandsSSave
andSLoad
which were really convenient including knowing the available sessions onTAB
. How is that to be done withmini.sessions
. If it is not built in how do I get this functionality?Thank you for the useful plugin 🙂