Code Monkey home page Code Monkey logo

nvim-possession's Introduction

Hi, I am Gennaro

In short:

  • I have a PhD in theoretical physics
  • I am employed in the field of machine learning and data science
  • I play the Najdorf and the Grünfeld with the black pieces

Here I write neovim plugins and command line applications. Have a look around!

Stats

Projects: quick links
neovim plugins
command line
gh extensions

Contact information:

I am happy to collaborate on neovim and command line projects: feel free to reach out!

nvim-possession's People

Contributors

emredogann avatar gennaro-tedesco avatar mariasolos avatar

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

nvim-possession's Issues

Loading a saved session doesn't restore properly

Hey,

I gave this a go and unfortunately I can't get it working, which may well be an issue on my end, but I would appreciate some pointers trying to figure it out.

I have loaded the plugin using Packer, and my config looks like this:

local possession = require("nvim-possession")
possession.setup()
vim.keymap.set("n", "<leader>sl", function()
  possession.list()
end)
vim.keymap.set("n", "<leader>sn", function()
  possession.new()
end)
vim.keymap.set("n", "<leader>su", function()
  possession.update()
end)

I can save a session and have it appear in the list correctly, but when I select one and hit enter, I get taken into that directory, but none of the files I had open are visible. It's like it has remembered the working directory of the session but no other details.

I also get a lot of other sessions pop up in the list that I am not explicitly creating via nivm-possession, it is like Vim is auto saving those, but they also fail to load correctly if I try to select them. Are there additional details I need to have this all work, or is the problem likely deep within my config? I am happy to debug further if required. Thanks!

Files that are deleted still shows in session file.

I have encountered a issue.

If i delete a file within ranger plugin in neovim, the session still shows it after loading it the next time, if i update it the same is happening. I tried another session plugin and it behaves the same.

I tried deleting the file within the command line, and then it works as expected.

Here is a video to understand better.

vokoscreenNG-2023-06-15_22-34-13.mp4

Replace "new" and "update" with just "save", buggy when launched at start

Hi,

i have a little suggestion:

a simple "save()" command would be great. I don't see the need to 2 different keybinds. If no session is detected, simply prompt for the new session's name. If a session is loaded, just update.

Additionally it'd be nice to be able to pass a string to the create/save function directly, so you can f.e. auto-create/update sessions when exiting nvim. F.e. last part of pwd or something.

A little bug: one cannot call "possession.list()" in the init function of lazy. You'll be in insert mode, but in the buffer and not the fzf window.

Small other thing: currently all session buffers are being displayed, is it possible to just show tabs?

Regards

Bug in README with lualine

When I tried the suggested configuration for lualine, it didn't work. The suggested setup is below

lualine.setup({
    sections = {
        lualine_c = {
            {
                require("nvim-possession").status,
                cond = function()
                    return require("nvim-possession").status() ~= nil
                end,
            },
        },
    }
})

I think there were two problems:

  • First, when a session is not loaded, the use of .status() in the condition seemed to throw an error, since the function does not exist.
  • Second, the first status returns a function, not a return value, so nothing gets printed even if the first issue is fixed.

Instead, I found that the following worked well.

lualine.setup({
    sections = {
        lualine_c = {
            {
              "require('nvim-possession').status()",
               cond = function()
                   return require("nvim-possession").status ~= nil
               end,
            },
        },
    }
})

There are two differences

  • The call to the status is in quotations, which I believe prevents it from being called unless the condition is true
  • The condition function uses status instead of status()

Posting here in case this is helpful - happy to open a PR to modify the README accordingly

Switch session will clean up buffers from current session?

i.e: when you're in a session and you want to switch to other session, clean up current buffers before jumping is more ideal.

I sometime find keep current buffers useful, sometime clean them up before jumping useful, so an option would help.

Add auto save on event, i.e: VimExit?

manually saving can be tedious, how about auto-save when VimExit?

This also mean that you don't need to have user input a name and then restore it later, can just use some kind of default from nvim like: /s/p/d/abc/session-folder.

Expose a delete() function

Would be a nice feature to expose the delete() function, so we can delete the current session (like the update or save), without having to open the list and then delete manually the session.

Close session

It would be nice to be able to close existing session without loading a new one.
In that use case, it would be nice to close all buffers and reset status (in case of possession being in lualine…)

Decouple fzf-lua to a plugin?

There're many plugins to manage smth called session/project that does the same thing: switch current cwd.

session management plugin will listen on cwd event and eventually does its job without ack of whatever trigger cwd, so fzf-lua support should be decoupled to another plugin.

Add auto-restore base on current dir, aware of neo-tree?

Hi, i like this plugin, this has potential.

but i use https://github.com/nvim-neo-tree/neo-tree.nvim and i can't call neo-tree when restore session or this plugin does not aware of tree, can you add support for pre_save_cmds and post_restore_cmds in setup() so tree can restore properly?

and can you add auto restore base on current dir, so we don't have to load ourselves

idk but with your plugin, my colorscheme restore correctly when i switch between session --> this huge plus compare to rmagatti/auto-session#198

Support telescope

Hello! I really want to start using sessions in neovim, but I've always seen the session plugins to be bloated with a bunch of features that I don't need, which is why I'm currently using yours.
Do you think you could support telescope.nvim? Like, in the setup, you could specify what you want to use, like:

require("nvim-possession").setup({
  viewer = "telescope|fzf",
  ...
})

autoload doesn't work

I am able to the other features list list(), but I'm not exactly sure how to get autoload to work. I have it set to true and am executing nvim from the current directory as the project I created the in.

Any suggestions on why autoload isn't working?

Plugin config:

  {
    "gennaro-tedesco/nvim-possession",
    dependencies = {
      "ibhagwan/fzf-lua",
    },
    config = true,
    opts = {
      autoload = true,
      autoswitch = {
        enable = true,
      },
      fzf_winopts = {
        width = 0.75,
      },
    },
    keys = function()
      local possession = require("nvim-possession")
      return {
        {
          "<leader>ql",
          function()
            possession.list()
          end,
          desc = "List Sessions",
          mode = "n",
        },
        {
          "<leader>qn",
          function()
            possession.new()
          end,
          desc = "New Session",
          mode = "n",
        },
        {
          "<leader>qu",
          function()
            possession.update()
          end,
          desc = "Update Session",
          mode = "n",
        },
        {
          "<leader>qd",
          function()
            possession.delete()
          end,
          desc = "Delete Session",
          mode = "n",
        },
      }
    end,
  },

Breaks on terminal

if a session is saved with terminal (tab in my case) opened it can't be loaded anymore

[Fzf-lua] fn_selected threw an error: ...e/nvim/lazy/nvim-possession/lua/nvim-possession/init.lua:73: /home/glaux/.local/share/
nvim/sessions/test, line 103: Vim(normal):Can't re-enter normal mode from terminal mode
stack traceback:
^I...laux/.local/share/nvim/lazy/fzf-lua/lua/fzf-lua/core.lua:179: in function <...laux/.local/share/nvim/lazy/fzf-lua/lua/fzf-
lua/core.lua:178>
^I[C]: in function 'source'
^I...e/nvim/lazy/nvim-possession/lua/nvim-possession/init.lua:73: in function 'action'
^I...x/.local/share/nvim/lazy/fzf-lua/lua/fzf-lua/actions.lua:72: in function 'act'
^I...laux/.local/share/nvim/lazy/fzf-lua/lua/fzf-lua/core.lua:93: in function 'fn_selected'
^I...laux/.local/share/nvim/lazy/fzf-lua/lua/fzf-lua/core.lua:177: in function <...laux/.local/share/nvim/lazy/fzf-lua/lua/fzf-
lua/core.lua:176>
^I[C]: in function 'xpcall'
^I...laux/.local/share/nvim/lazy/fzf-lua/lua/fzf-lua/core.lua:176: in function <...laux/.local/share/nvim/lazy/fzf-lua/lua/fzf-
lua/core.lua:170>

Ubuntu 22.04.3 LTS and Nvim:

NVIM v0.10.0-dev
Build type: RelWithDebInfo
LuaJIT 2.1.0-beta3
Run "nvim -V1 -v" for more info

How to "close" session?

I'd like to "close" a session to return to the dashboard and being able to start a new session from scratch or don't use any session at all. This is possible in vim-startify and posession.nvim. Can I somehow do this using this plugin?

Auto-create session path

Great plugin--just what I needed.

I have a request that it automatically creates the session path if it doesn't exists. I periodically clear out my .local/share/nvim folder and I'd rather not have to manually recreate the session folder. I know I can store it somewhere else, but it would be nice to keep it all together in the same directory tree.

The autoload setting makes the loaded buffer innactive

Hello again! Another issue. I have 3, so ill open them apart for convenience.

When autoload = true in plugin setup, when i enter neovim and the session loads, the file that opens(whatever opens) is somehow innactive, doesnt have the colorscheme, lsp isnt working, so i assume its something related to lazy neovim, the keybinding are in plugins.lua and the setup config is a separate file that i load with init.lua

Keymaps:
image

Setup config:
image

Init.lua:
image

One way to fix that i use :e and the buffer refreshes

autoload cause double lualine in lazyvim

I clone lazyvim starter and then add possession.lua to plugins folder with this configuration

-- stylua: ignore
return {
  { "folke/persistence.nvim", enabled = false },
  {
    "gennaro-tedesco/nvim-possession",
    lazy = false,
    dependencies = {
        {"ibhagwan/fzf-lua"},
    },
    keys = {
			{ '<leader>qe', function() require("nvim-possession").list() end, silent = true, mode = { "n" }, desc = "Session Menu"},
			{ '<leader>qn', function() require("nvim-possession").new() end, silent = true, mode = { 'n' }, desc = "New Session"},
			{ '<leader>qu', function() require("nvim-possession").update() end, silent = true, mode = { 'n' }, desc = "Update Session"},
    },
    config = function()
        require("nvim-possession").setup({
            autoload = true,
        })
    end,
  }
}

but when I enable autoload I got double lualine when changing tab
image

Here are step to reproduce

  • create new Tab ( with <leader><Tab><Tab> )
  • quit and reopen
  • go to other Tab ( with <leader><Tab>[ )
  • got double lualine as in picture

This does not happens when I disable autoload and load session normally through require("nvim-possession").list().
You can try this with this repo https://github.com/phootip/lazyvim/tree/test-possession

Bad filepath error (No such file or directory)

I created the sessions/ directory and used the default binding <leader>sn to create a new session. However, when I go to load that same session file from the session list (<leader>sl) then I get this error:
image

It looks like to me that there is some junk characters at the beginning of entry_str messing up the file path.
They are not regular whitespace it seems as a vim.trim(entry_str) did not work.
If I strip the beginning characters via a substring, it works fine with no errors:
image

Why is there whitespace at the start of entry_str?

EDIT:
I just noticed that my possession.list() window looks very different from the list menu in the README gif. Maybe a change with fzf?

Versions

fzf-lua: Main branch, commit 2670983 (most recent version as of posting)
nvim-possession: Main branch, commit 27f7535 (most recent version as of posting)

NVIM v0.9.2-dev-25+g470017c9a
Build type: Release (Built from source)
Using lazy.nvim

Plugin doesn't work

I have in my init.vim:

let mapleader=" "
require("nvim-possession-conf")

This file's contents is:

require('nvim-possession').setup({
  config = true,
  init = function()
      local possession = require("nvim-possession")
      vim.keymap.set("n", "<leader>sl", function()
          possession.list()
      end)
      vim.keymap.set("n", "<leader>sn", function()
          possession.new()
      end)
      vim.keymap.set("n", "<leader>su", function()
          possession.update()
      end)
      vim.keymap.set("n", "<leader>sd", function()
          possession.delete()
      end)
  end,
  autoload = true,
  autosave = true,
  autoswitch = {
      enable = true,
      exclude_ft = {},
  },
  fzf_winopts = {
      -- any valid fzf-lua winopts options, for instance
      width = 0.5,
      preview = {
          vertical = "right:30%"
      }
  }
})

The leader is set to .

Starting nvim is error-free.

I'm expecting <space>sn or <space>sl to give me results (new or list) but it appears that the key mappings are not set. Apologies if this is a generic config problem. My other plugins show how to do things with vimscript.

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.