up
This commit is contained in:
24
lua/custom/plugins/neotree.lua
Normal file
24
lua/custom/plugins/neotree.lua
Normal file
@@ -0,0 +1,24 @@
|
||||
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
|
||||
Reference in New Issue
Block a user