Adds automatic reopening

This commit is contained in:
Michel Fedde 2025-06-04 14:30:40 +02:00
parent 88bda96496
commit 6dd971b541
2 changed files with 30 additions and 4 deletions

View file

@ -1,12 +1,21 @@
local fs = {}
local function startswith(string, start)
return string:sub(1, #start) == start
end
function fs.getCurrentPath()
local currentBuffer = vim.fn.expand("%")
print(currentBuffer)
end
function fs.getRootPath()
local initialArguments = vim.v.argv
local requestedFile = initialArguments[#initialArguments]
local path = vim.fs.abspath(requestedFile)
if vim.fn.isdirectory(path) == 1 then
return path
end
return LazyVim.root()
end
return fs

View file

@ -0,0 +1,17 @@
local fs = require("functions.fs")
return {
"folke/snacks.nvim",
keys = {
{
"<leader>e",
function()
local rootdirectory = fs.getRootPath()
Snacks.explorer({ cwd = rootdirectory })
end,
desc = "Explorer Snacks (root directory)",
remap = true,
},
},
}