Fixes issues with switching to snacks explorer

This commit is contained in:
Michel Fedde 2025-02-16 22:07:56 +01:00
parent 1699bd2574
commit 8892845c03
6 changed files with 12 additions and 17 deletions

View file

@ -15,11 +15,11 @@ vim.api.nvim_create_user_command("CreateRandomFile", function()
wordsFinal = wordsFinal .. tocamel(word)
end
local currentPath = fs.getCurrentPath()
local directory = currentPath
if vim.fn.isdirectory(currentPath) == 0 then
directory = vim.fs.dirname(currentPath)
local picker = Snacks.picker.get({ source = "explorer" })
local currentFile = picker[1]:current().file
local directory = currentFile
if vim.fn.isdirectory(directory) == 0 then
directory = vim.fs.dirname(directory)
end
local path = vim.fs.joinpath(directory, wordsFinal .. ".md")