From 8037b20d9cf251916ffe1370fe3e5811b868969a Mon Sep 17 00:00:00 2001 From: Valentin GHIRARDI Date: Fri, 19 Sep 2025 00:36:56 +0200 Subject: [PATCH] modified structure --- README.md | 95 +------------------ init.lua | 22 +---- lua/config.lua | 90 ++++++++++++++++++ lua/core/plugin_loader.lua | 30 ++++++ lua/{ => core}/plugins/catppuccin.lua | 0 lua/{ => core}/plugins/lualine.lua | 0 .../plugins/nvim_tree.lua} | 6 +- lua/core/plugins/nvim_treesitter.lua | 34 +++++++ lua/{ => core}/plugins/telescope.lua | 13 +-- lua/core/vim.lua | 33 +++++++ lua/mappings.lua | 13 --- lua/options.lua | 17 ---- lua/plugins.lua | 7 -- lua/plugins/nvim-treesitter.lua | 73 -------------- 14 files changed, 201 insertions(+), 232 deletions(-) create mode 100644 lua/config.lua create mode 100644 lua/core/plugin_loader.lua rename lua/{ => core}/plugins/catppuccin.lua (100%) rename lua/{ => core}/plugins/lualine.lua (100%) rename lua/{plugins/nvim-tree.lua => core/plugins/nvim_tree.lua} (80%) create mode 100644 lua/core/plugins/nvim_treesitter.lua rename lua/{ => core}/plugins/telescope.lua (58%) create mode 100644 lua/core/vim.lua delete mode 100644 lua/mappings.lua delete mode 100644 lua/options.lua delete mode 100644 lua/plugins.lua delete mode 100644 lua/plugins/nvim-treesitter.lua diff --git a/README.md b/README.md index d808fac..1333ed7 100644 --- a/README.md +++ b/README.md @@ -1,94 +1 @@ -# Neovim Configuration - -Bienvenue dans ma configuration Neovim ! Ce dépôt contient tous les fichiers nécessaires pour avoir un environnement Neovim moderne, rapide et productif, avec des plugins pour le développement, la navigation et l’autocomplétion. - ---- - -## Table des matières - -* [Installation](#installation) -* [Structure](#structure) -* [Plugins](#plugins) -* [Mappings](#mappings) -* [Licence](#licence) - ---- - -## Installation - -1. Clone ce dépôt dans ton répertoire de configuration Neovim (\~/.config/nvim) : - -```bash -git clone https://git.ghirardiv.fr/valentin/neovim-config.git ~/.config/nvim -``` - -2. Installe [Neovim](https://neovim.io) si ce n'est pas déjà fait. -3. Lance Neovim et l'installation des plugins devrait se lancer automatiquement. -4. Code ! - ---- - -## Structure - -```text -~/.config/nvim/ -├── init.lua # Script d'initialisation -└── lua/ - ├── options.lua # Configuration des options générales - ├── mappings.lua # Configuration des raccourcis clavier généraux - ├── plugins.lua # Chargement des plugins - └── plugins/ # Configurations individuelles des plugins - ├── catpuccin.lua - ├── nvim-tree.lua - ├── telescope.lua - ├── lualine.lua - └── nvim-treesitter.lua -``` - ---- - -## Plugins - -### 1. [catppuccin](https://github.com/catppuccin/nvim) - -* **Description** : Personnalisation du thème - -### 2. [nvim-tree](https://github.com/nvim-tree/nvim-tree.lua) - -* **Description** : Explorateur de fichiers -* **Mappings** : - - * `e` → Ouvrir/fermer l'explorateur de fichiers - -### 3. [telescope](https://github.com/nvim-telescope/telescope.nvim) - -* **Description** : Moteur de recherche de fichiers et de texte -* **Mappings** : - - * `f` → Ouvrir la recherche de fichiers - * `g` → Ouvrir la recherche textuelle - -### 4. [lualine](https://github.com/nvim-lualine/lualine.nvim) - -* **Description** : Barre de status - -### 5. [nvim-treesitter](https://github.com/nvim-treesitter/nvim-treesitter) - -* **Description** : Analyseur de code -* **Mappings** : - - * `` → Commencer/agrandir la sélection syntaxique - * `` → Réduire la sélection syntaxique - ---- - -## Mappings - -* `` → Annuler la dernière modification -* `` → Rétablir la dernière modification - ---- - -## Licence - -MIT License © [GHIRARDI Valentin](https://git.ghirardiv.fr/valentin/neovim-config) +TODO diff --git a/init.lua b/init.lua index ef9d635..ca87599 100644 --- a/init.lua +++ b/init.lua @@ -1,20 +1,2 @@ -require("options") -require("mappings") - -local lazypath = vim.fn.stdpath("data") .. "/lazy/lazy.nvim" - -if not vim.loop.fs_stat(lazypath) then - vim.fn.system({ - "git", - "clone", - "--filter=blob:none", - "https://github.com/folke/lazy.nvim.git", - lazypath, - }) -end - -vim.opt.rtp:prepend(lazypath) - -local plugins = require("plugins") - -require("lazy").setup(plugins) +require("core.vim") +require("core.plugin_loader") diff --git a/lua/config.lua b/lua/config.lua new file mode 100644 index 0000000..2afc318 --- /dev/null +++ b/lua/config.lua @@ -0,0 +1,90 @@ +return { + vim = { + options = { + -- Define leader character + leader = " ", + + -- Define tab size + tab_size = 4, + + line_numbers = { + -- Enable line numbers + enabled = true, + + -- Set relative line numbers + relative = false + } + }, + + mappings = { + -- Undo last edit (insert) + undo = "", + + -- Redo last edit (insert) + redo = "" + } + }, + + plugins = { + catppuccin = { + -- Enable catppuccin + enabled = true, + }, + + nvim_tree = { + -- Enable nvim-tree + enabled = true, + + mappings = { + -- Toggle file explorer (normal) + toggle_file_explorer = "e" + } + }, + + telescope = { + -- Enable telescope + enabled = true, + + mappings = { + -- Open file finder (normal) + open_file_finder = "f", + + -- Open text finder (normal) + open_text_finder = "g" + } + }, + + lualine = { + -- Enable lualine + enabled = true + }, + + nvim_treesitter = { + -- Enable nvim-treesitter + enabled = true, + + options = { + parsers = { + "angular", "asm", "bash", "c", "c_sharp", "cmake", + "cpp", "css", "csv", "dockerfile", "gitignore", "go", + "groovy", "html", "htmldjango", "http", "java", "javascript", + "json", "kotlin", "lua", "make", "markdown", "nginx", + "ocaml", "odin", "pascal", "php", "powershell", "python", + "ruby", "rust", "scala", "sql", "toml", "tsx", + "twig", "typescript", "vim", "vue", "xml", "yaml" + } + }, + + mappings = { + -- Start incremental selection (normal/visual) + start_selection = "", + + -- Increment incremental selection (visual) + increment_selection = "", + + -- Decrement incremental selection (visual) + decrement_selection = "" + } + } + } +} diff --git a/lua/core/plugin_loader.lua b/lua/core/plugin_loader.lua new file mode 100644 index 0000000..f7a1047 --- /dev/null +++ b/lua/core/plugin_loader.lua @@ -0,0 +1,30 @@ +local config = require("config").plugins + +-- Plugin loader + +local lazypath = vim.fn.stdpath("data") .. "/lazy/lazy.nvim" + +if not vim.loop.fs_stat(lazypath) then + vim.fn.system({ + "git", + "clone", + "--filter=blob:none", + "https://github.com/folke/lazy.nvim.git", + lazypath, + }) +end + +vim.opt.rtp:prepend(lazypath) + +-- Plugins + +local plugins = {} + +for name, info in pairs(config) do + if info.enabled then + local plugin = require("core.plugins." .. name) + table.insert(plugins, plugin) + end +end + +require("lazy").setup(plugins) diff --git a/lua/plugins/catppuccin.lua b/lua/core/plugins/catppuccin.lua similarity index 100% rename from lua/plugins/catppuccin.lua rename to lua/core/plugins/catppuccin.lua diff --git a/lua/plugins/lualine.lua b/lua/core/plugins/lualine.lua similarity index 100% rename from lua/plugins/lualine.lua rename to lua/core/plugins/lualine.lua diff --git a/lua/plugins/nvim-tree.lua b/lua/core/plugins/nvim_tree.lua similarity index 80% rename from lua/plugins/nvim-tree.lua rename to lua/core/plugins/nvim_tree.lua index 45d6883..e2e62f4 100644 --- a/lua/plugins/nvim-tree.lua +++ b/lua/core/plugins/nvim_tree.lua @@ -1,3 +1,6 @@ +local config = require("config").plugins.nvim_tree +local mappings = config.mappings + return { "nvim-tree/nvim-tree.lua", @@ -41,8 +44,7 @@ return { } }) - -- Ouvrir/fermer l'explorateur de fichiers - vim.keymap.set("n", "e", ":NvimTreeToggle", { + vim.keymap.set("n", mappings.toggle_file_explorer, ":NvimTreeToggle", { desc = "Toggle file explorer", noremap = true, silent = true diff --git a/lua/core/plugins/nvim_treesitter.lua b/lua/core/plugins/nvim_treesitter.lua new file mode 100644 index 0000000..da5a677 --- /dev/null +++ b/lua/core/plugins/nvim_treesitter.lua @@ -0,0 +1,34 @@ +local config = require("config").plugins.nvim_treesitter +local options = config.options +local mappings = config.mappings + +return { + "nvim-treesitter/nvim-treesitter", + + build = ":TSUpdate", + + config = function() + local nvim_treesitter_configs = require("nvim-treesitter.configs") + + nvim_treesitter_configs.setup({ + ensure_installed = options.parsers, + + highlight = { + enable = true + }, + + indent = { + enable = true + }, + + incremental_selection = { + enable = true, + keymaps = { + init_selection = mappings.start_selection, + node_incremental = mappings.increment_selection, + node_decremental = mappings.decrement_selection + } + } + }) + end +} diff --git a/lua/plugins/telescope.lua b/lua/core/plugins/telescope.lua similarity index 58% rename from lua/plugins/telescope.lua rename to lua/core/plugins/telescope.lua index 55148b7..ec46e68 100644 --- a/lua/plugins/telescope.lua +++ b/lua/core/plugins/telescope.lua @@ -1,3 +1,6 @@ +local config = require("config").plugins.telescope +local mappings = config.mappings + return { "nvim-telescope/telescope.nvim", @@ -16,16 +19,14 @@ return { } }) - -- Ouvrir la recherche de fichiers - vim.keymap.set("n", "f", telescope_builtin.find_files, { - desc = "Find files", + vim.keymap.set("n", mappings.open_file_finder, telescope_builtin.find_files, { + desc = "Open file finder", noremap = true, silent = true }) - -- Ouvrir la recherche textuelle - vim.keymap.set("n", "g", telescope_builtin.live_grep, { - desc = "Live grep", + vim.keymap.set("n", mappings.open_text_finder, telescope_builtin.live_grep, { + desc = "Open text finder", noremap = true, silent = true }) diff --git a/lua/core/vim.lua b/lua/core/vim.lua new file mode 100644 index 0000000..2964643 --- /dev/null +++ b/lua/core/vim.lua @@ -0,0 +1,33 @@ +local config = require("config").vim + +-- Options + +local options = config.options + +vim.opt.guicursor = "" + +vim.opt.number = options.line_numbers.enabled +vim.opt.relativenumber = options.line_numbers.relative + +vim.opt.shiftwidth = options.tab_size + +vim.g.mapleader = options.leader +vim.g.maplocalleader = options.leader + +vim.opt.clipboard = "unnamedplus" + +-- Mappings + +local mappings = config.mappings + +vim.keymap.set("i", mappings.undo, ":undo", { + desc = "Undo last edit", + noremap = true, + silent = true +}) + +vim.keymap.set("i", mappings.redo, ":redo", { + desc = "Redo last edit", + noremap = true, + silent = true +}) diff --git a/lua/mappings.lua b/lua/mappings.lua deleted file mode 100644 index a221c90..0000000 --- a/lua/mappings.lua +++ /dev/null @@ -1,13 +0,0 @@ --- Annuler la dernière modification -vim.keymap.set("i", "", ":undo", { - desc = "Undo last edit", - noremap = true, - silent = true -}) - --- Rétablir la dernière modification -vim.keymap.set("i", "", ":redo", { - desc = "Redo last edit", - noremap = true, - silent = true -}) diff --git a/lua/options.lua b/lua/options.lua deleted file mode 100644 index 6658fcd..0000000 --- a/lua/options.lua +++ /dev/null @@ -1,17 +0,0 @@ --- Désactiver le changement de curseur -vim.opt.guicursor = "" - - -- Activer les numéros de ligne -vim.opt.number = true --- Désactiver les numéros de ligne relatifs -vim.opt.relativenumber = false - --- Définir la taille du tab à 4 -vim.opt.shiftwidth = 4 - --- Définir le leader à espace -vim.g.mapleader = " " -vim.g.maplocalleader = " " - --- Activer le presse-papier système -vim.opt.clipboard = "unnamedplus" diff --git a/lua/plugins.lua b/lua/plugins.lua deleted file mode 100644 index c00d38e..0000000 --- a/lua/plugins.lua +++ /dev/null @@ -1,7 +0,0 @@ -return { - require("plugins.catppuccin"), - require("plugins.nvim-tree"), - require("plugins.telescope"), - require("plugins.lualine"), - require("plugins.nvim-treesitter") -} diff --git a/lua/plugins/nvim-treesitter.lua b/lua/plugins/nvim-treesitter.lua deleted file mode 100644 index 187b286..0000000 --- a/lua/plugins/nvim-treesitter.lua +++ /dev/null @@ -1,73 +0,0 @@ -return { - "nvim-treesitter/nvim-treesitter", - - build = ":TSUpdate", - - config = function() - local nvim_treesitter_configs = require("nvim-treesitter.configs") - - nvim_treesitter_configs.setup({ - ensure_installed = { - "angular", - "asm", - "bash", - "c", - "c_sharp", - "cmake", - "cpp", - "css", - "csv", - "dockerfile", - "gitignore", - "go", - "groovy", - "html", - "htmldjango", - "http", - "java", - "javascript", - "json", - "kotlin", - "lua", - "make", - "markdown", - "nginx", - "ocaml", - "odin", - "pascal", - "php", - "powershell", - "python", - "ruby", - "rust", - "scala", - "sql", - "toml", - "tsx", - "twig", - "typescript", - "vim", - "vue", - "xml", - "yaml" - }, - - highlight = { - enable = true - }, - - indent = { - enable = true - }, - - incremental_selection = { - enable = true, - keymaps = { - init_selection = "", -- Commencer la sélection syntaxique - node_incremental = "", -- Agrandir la sélection syntaxique - node_decremental = "" -- Réduire la sélection syntaxique - } - } - }) - end -}