From ecaf50a044865e3b5277bcbd66c47ab1cc68b95f Mon Sep 17 00:00:00 2001 From: Jeff LANCE Date: Mon, 4 Aug 2025 17:36:35 +0200 Subject: [PATCH] up --- init.lua | 30 +++++++------------ lua/custom/keymaps/init.lua | 2 ++ lua/custom/keymaps/neotree.lua | 7 +++++ lua/custom/plugins/neotree.lua | 24 +++++++++++++++ lua/keymaps/init.lua | 7 ----- lua/keymaps/neotree.lua | 5 ---- lua/{ => kickstart/core}/autocommands.lua | 17 +++++++++++ .../base.lua => kickstart/core/keymaps.lua} | 0 lua/{ => kickstart/core}/lazy-bootstrap.lua | 0 lua/{ => kickstart/core}/lazy-plugins.lua | 0 lua/{ => kickstart/core}/options.lua | 10 +++++++ 11 files changed, 71 insertions(+), 31 deletions(-) create mode 100644 lua/custom/keymaps/init.lua create mode 100644 lua/custom/keymaps/neotree.lua create mode 100644 lua/custom/plugins/neotree.lua delete mode 100644 lua/keymaps/init.lua delete mode 100644 lua/keymaps/neotree.lua rename lua/{ => kickstart/core}/autocommands.lua (53%) rename lua/{keymaps/base.lua => kickstart/core/keymaps.lua} (100%) rename lua/{ => kickstart/core}/lazy-bootstrap.lua (100%) rename lua/{ => kickstart/core}/lazy-plugins.lua (100%) rename lua/{ => kickstart/core}/options.lua (87%) diff --git a/init.lua b/init.lua index be798f7..b0159db 100644 --- a/init.lua +++ b/init.lua @@ -84,29 +84,21 @@ I hope you enjoy your Neovim journey, P.S. You can delete this when you're done too. It's your config now! :) --]] --- Set as the leader key --- See `:help mapleader` --- NOTE: Must happen before plugins are loaded (otherwise wrong leader will be used) -vim.g.mapleader = ';' -vim.g.maplocalleader = ';' - --- Set to true if you have a Nerd Font installed and selected in the terminal -vim.g.have_nerd_font = true - --- [[ Setting options ]] -require 'options' - --- [[ Keymaps ]] -require 'keymaps' - --- [[ Basic Autocommands ]] -require 'autocommands' +-- [[ Core options ]] +require 'kickstart.core.options' -- [[ Install `lazy.nvim` plugin manager ]] -require 'lazy-bootstrap' +require 'kickstart.core.lazy-bootstrap' -- [[ Configure and install plugins ]] -require 'lazy-plugins' +require 'kickstart.core.lazy-plugins' + +-- [[ Basic Autocommands ]] +require 'kickstart.core.autocommands' + +-- [[ Keymaps ]] +require 'kickstart.core.keymaps' +require 'custom.keymaps' -- The line beneath this is called `modeline`. See `:help modeline` -- vim: ts=2 sts=2 sw=2 et diff --git a/lua/custom/keymaps/init.lua b/lua/custom/keymaps/init.lua new file mode 100644 index 0000000..080f223 --- /dev/null +++ b/lua/custom/keymaps/init.lua @@ -0,0 +1,2 @@ +-- load which-key mappings +require 'custom.keymaps.neotree' diff --git a/lua/custom/keymaps/neotree.lua b/lua/custom/keymaps/neotree.lua new file mode 100644 index 0000000..8453efc --- /dev/null +++ b/lua/custom/keymaps/neotree.lua @@ -0,0 +1,7 @@ +local wk = require 'which-key' +local neotree = require 'custom.plugins.neotree' + +wk.add({ + { "f", group = "file" }, -- group + { 'fe', neotree.smart_open(), desc = 'Fichiers...', mode = 'n' }, +}) diff --git a/lua/custom/plugins/neotree.lua b/lua/custom/plugins/neotree.lua new file mode 100644 index 0000000..01392a7 --- /dev/null +++ b/lua/custom/plugins/neotree.lua @@ -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 diff --git a/lua/keymaps/init.lua b/lua/keymaps/init.lua deleted file mode 100644 index bfc728a..0000000 --- a/lua/keymaps/init.lua +++ /dev/null @@ -1,7 +0,0 @@ --- local wk = require 'kickstart.plugins.which-key' - --- load neovim standard mappings -require 'keymaps.base' - --- load which-key mappings ---require 'keymaps.neotree' diff --git a/lua/keymaps/neotree.lua b/lua/keymaps/neotree.lua deleted file mode 100644 index 24d7a85..0000000 --- a/lua/keymaps/neotree.lua +++ /dev/null @@ -1,5 +0,0 @@ -local wk = require 'kickstart.plugins.which-key' - -wk.register { - { 'e', 'Neotree toggle reveal', desc = 'Fichiers...', mode = 'n' }, -} diff --git a/lua/autocommands.lua b/lua/kickstart/core/autocommands.lua similarity index 53% rename from lua/autocommands.lua rename to lua/kickstart/core/autocommands.lua index 7fef745..42f2e35 100644 --- a/lua/autocommands.lua +++ b/lua/kickstart/core/autocommands.lua @@ -12,5 +12,22 @@ vim.api.nvim_create_autocmd('TextYankPost', { end, }) +-- -- Delay start of neotree smart open command +-- -- +-- local ok, neotree_utils = pcall(require, "custom.plugins.neotree") +-- if not ok then +-- return +-- end + +-- vim.api.nvim_create_autocmd("VimEnter", { +-- callback = function() +-- vim.defer_fn(function() +-- if vim.bo.filetype == "starter" then +-- neotree_utils.smart_open() +-- end +-- end, 100) -- délai pour laisser mini.starter s'afficher +-- end, +-- }) + -- The line beneath this is called `modeline`. See `:help modeline` -- vim: ts=2 sts=2 sw=2 et \ No newline at end of file diff --git a/lua/keymaps/base.lua b/lua/kickstart/core/keymaps.lua similarity index 100% rename from lua/keymaps/base.lua rename to lua/kickstart/core/keymaps.lua diff --git a/lua/lazy-bootstrap.lua b/lua/kickstart/core/lazy-bootstrap.lua similarity index 100% rename from lua/lazy-bootstrap.lua rename to lua/kickstart/core/lazy-bootstrap.lua diff --git a/lua/lazy-plugins.lua b/lua/kickstart/core/lazy-plugins.lua similarity index 100% rename from lua/lazy-plugins.lua rename to lua/kickstart/core/lazy-plugins.lua diff --git a/lua/options.lua b/lua/kickstart/core/options.lua similarity index 87% rename from lua/options.lua rename to lua/kickstart/core/options.lua index 01988e6..7784d87 100644 --- a/lua/options.lua +++ b/lua/kickstart/core/options.lua @@ -1,3 +1,13 @@ +-- [[ Global settings ]] +-- Set as the leader key +-- See `:help mapleader` +-- NOTE: Must happen before plugins are loaded (otherwise wrong leader will be used) +vim.g.mapleader = ';' +vim.g.maplocalleader = ';' + +-- Set to true if you have a Nerd Font installed and selected in the terminal +vim.g.have_nerd_font = true + -- [[ Setting options ]] -- See `:help vim.o` -- NOTE: You can change these options as you wish!