gennaro-tedesco / nvim-possession

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

Expose a delete() function #22

Closed BrunoKrugel closed 1 year ago

BrunoKrugel commented 1 year ago

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.

gennaro-tedesco commented 1 year ago

It can be done: could you specify how you would like the function to work? If I understand correctly, it should simply check if you are in a loaded session and if so, delete it from disk?

BrunoKrugel commented 1 year ago

Exactly, so we can have, for example:

{
    "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,
}
gennaro-tedesco commented 1 year ago

I have created a draft PR to address this issue.

Could you please help me test if this is what you wished? You can install the branch delete_local_session (via your package manager of choice) and <leader>sd is the suggested mapping to be set (as you mention above).

BrunoKrugel commented 1 year ago

it works!

gennaro-tedesco commented 1 year ago

I will have another go at the code to see if I can polish it a little and test it again: will merge in the next days (I may be busy at work so bear with me, but I don't forget :p)

gennaro-tedesco commented 1 year ago

This change has been included in the latest release v0.0.9. Just update your plugin via your package manager of choice and you're good to go :)