Files
nvim-modular/lua/custom/plugins/neotree.lua
2025-08-04 17:36:35 +02:00

25 lines
628 B
Lua

local M = {}
function M.smart_open()
local bufname = vim.api.nvim_buf_get_name(0)
local is_real_file = vim.fn.filereadable(bufname) == 1
local cwd = vim.fn.getcwd()
local target_path = "~"
if is_real_file then
target_path = vim.fn.fnamemodify(bufname, ":p:h")
elseif bufname ~= "" then
-- buffer avec un nom mais fichier inexistant (ex: nouveau buffer)
target_path = "~"
elseif vim.bo.filetype == "starter" then
-- buffer mini.starter
target_path = "~"
end
-- Appel de Neotree avec le bon dossier
vim.cmd("Neotree toggle reveal=true position=float dir=" .. target_path)
end
return M