This commit is contained in:
2025-08-04 17:36:35 +02:00
parent 9800f5d265
commit ecaf50a044
11 changed files with 71 additions and 31 deletions

View File

@@ -0,0 +1,2 @@
-- load which-key mappings
require 'custom.keymaps.neotree'

View File

@@ -0,0 +1,7 @@
local wk = require 'which-key'
local neotree = require 'custom.plugins.neotree'
wk.add({
{ "<leader>f", group = "file" }, -- group
{ '<leader>fe', neotree.smart_open(), desc = 'Fichiers...', mode = 'n' },
})

View 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