gennaro-tedesco / nvim-possession

📌 the no-nonsense session manager
MIT License
215 stars 7 forks source link

I get an error when calling the setup function: Vim:E499: Empty file name for '%' or '#', only works with ":p:h" #40

Closed emilBeBri closed 2 weeks ago

emilBeBri commented 4 months ago

Hi so when I basically just copy pasted your config, using lazy:


{
    "gennaro-tedesco/nvim-possession",
    dependencies = {
        "ibhagwan/fzf-lua",
    },
    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,
}

and then putting this at the very end of my init.lua:


require("nvim-possession").setup({
    autoload = true -- default false
})

I then get this error:


Error detected while processing (PATH-TO-MY-CONFIG-DIR)/init.lua:
E5113: Error while calling lua chunk: .../nvim/lazy/nvim-possession/lua/nvim-possession/
utils.lua:62: Vim:E499: Empty file name for '%' or '#', only works with ":p:h"
stack traceback:
        [C]: in function 'source'
        .../nvim/lazy/nvim-possession/lua/nvim-possession/utils.lua:62: in function 'aut
oload'
        ...e/nvim/lazy/nvim-possession/lua/nvim-possession/init.lua:148: in function 'se
tup'
        (PATH-TO-MY-CONFIG-DIR)/init.lua:1041: in main chunk

Not sure what that could be about? On Endeavour OS (Arch based), fully updated.

gennaro-tedesco commented 4 months ago

This error is generated when autoloading the current session in the current working directory as per here. Do you have a session saved in the current working directory and, if so, does said session contain perhaps tabs or empty buffers (with no filenames) that you have mistakenly attached to said session when creating it?

Generally speaking I would debug it as follows:

  1. ensure that the plugin works and loads sessions correctly with autoload = false (so manual loading, no autoloading for the moment)
  2. If 1. holds true, create a session in the current working directory containing one buffer file only and check that the autoload mechanism works fine
  3. if 2. holds true, reproduce the autoload with the session you're currently trying to load (most likely, as said, there must be some special tabs/buffers saved without any name - or similar).