From 7e601970b09bbc1fd0c52a114d02a53ca05b2aea Mon Sep 17 00:00:00 2001 From: Valentin GHIRARDI Date: Thu, 18 Sep 2025 16:12:20 +0200 Subject: [PATCH] setup nvim-treesitter --- README.md | 23 ++++++++++- lua/mappings.lua | 4 +- lua/options.lua | 3 ++ lua/plugins.lua | 5 ++- lua/plugins/catppuccin.lua | 6 ++- lua/plugins/lualine.lua | 6 ++- lua/plugins/nvim-tree.lua | 9 +++- lua/plugins/nvim-treesitter.lua | 73 +++++++++++++++++++++++++++++++++ lua/plugins/telescope.lua | 6 ++- 9 files changed, 125 insertions(+), 10 deletions(-) create mode 100644 lua/plugins/nvim-treesitter.lua diff --git a/README.md b/README.md index a475aad..db680b2 100644 --- a/README.md +++ b/README.md @@ -4,6 +4,8 @@ Bienvenue dans ma configuration Neovim ! Ce dépôt contient tous les fichiers n --- + + ## Table des matières * [Installation](#installation) @@ -14,6 +16,8 @@ Bienvenue dans ma configuration Neovim ! Ce dépôt contient tous les fichiers n --- + + ## Installation 1. Clone ce dépôt dans ton répertoire de configuration Neovim (\~/.config/nvim) : @@ -28,6 +32,8 @@ git clone https://git.ghirardiv.fr/valentin/neovim-config.git ~/.config/nvim --- + + ## Structure ```text @@ -41,11 +47,14 @@ git clone https://git.ghirardiv.fr/valentin/neovim-config.git ~/.config/nvim ├── catpuccin.lua ├── nvim-tree.lua ├── telescope.lua - └── lualine.lua + ├── lualine.lua + └── nvim-treesitter.lua ``` --- + + ## Plugins ### 1. [catppuccin](https://github.com/catppuccin/nvim) @@ -71,8 +80,18 @@ git clone https://git.ghirardiv.fr/valentin/neovim-config.git ~/.config/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 @@ -80,6 +99,8 @@ git clone https://git.ghirardiv.fr/valentin/neovim-config.git ~/.config/nvim --- + + ## Licence MIT License © [GHIRARDI Valentin](https://git.ghirardiv.fr/valentin/neovim-config) diff --git a/lua/mappings.lua b/lua/mappings.lua index 73bf37b..a221c90 100644 --- a/lua/mappings.lua +++ b/lua/mappings.lua @@ -1,11 +1,11 @@ --- Control + z : Annuler la dernière modification +-- Annuler la dernière modification vim.keymap.set("i", "", ":undo", { desc = "Undo last edit", noremap = true, silent = true }) --- Control + y : Rétablir la dernière modification +-- Rétablir la dernière modification vim.keymap.set("i", "", ":redo", { desc = "Redo last edit", noremap = true, diff --git a/lua/options.lua b/lua/options.lua index aaa7fd7..6658fcd 100644 --- a/lua/options.lua +++ b/lua/options.lua @@ -12,3 +12,6 @@ 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 index 22599fc..c00d38e 100644 --- a/lua/plugins.lua +++ b/lua/plugins.lua @@ -1,6 +1,7 @@ return { require("plugins.catppuccin"), - require("plugins.lualine"), require("plugins.nvim-tree"), - require("plugins.telescope") + require("plugins.telescope"), + require("plugins.lualine"), + require("plugins.nvim-treesitter") } diff --git a/lua/plugins/catppuccin.lua b/lua/plugins/catppuccin.lua index 92cf827..908fc1a 100644 --- a/lua/plugins/catppuccin.lua +++ b/lua/plugins/catppuccin.lua @@ -1,11 +1,15 @@ return { "catppuccin/nvim", + config = function() - require("catppuccin").setup({ + local catppuccin = require("catppuccin") + + catppuccin.setup({ flavour = "mocha", transparant_background = true, show_end_of_buffer = true }) + vim.cmd("colorscheme catppuccin") end } diff --git a/lua/plugins/lualine.lua b/lua/plugins/lualine.lua index e2edd78..6179945 100644 --- a/lua/plugins/lualine.lua +++ b/lua/plugins/lualine.lua @@ -1,12 +1,16 @@ return { "nvim-lualine/lualine.nvim", + dependencies = { { "nvim-tree/nvim-web-devicons", } }, + config = function() - require("lualine").setup({ + local lualine = require("lualine") + + lualine.setup({ options = { theme = "catppuccin" } diff --git a/lua/plugins/nvim-tree.lua b/lua/plugins/nvim-tree.lua index bc44480..45d6883 100644 --- a/lua/plugins/nvim-tree.lua +++ b/lua/plugins/nvim-tree.lua @@ -1,10 +1,12 @@ return { "nvim-tree/nvim-tree.lua", + dependencies = { { "nvim-tree/nvim-web-devicons", } }, + config = function() vim.g.loaded_netrw = 1 vim.g.loaded_netrwPlugin = 1 @@ -16,25 +18,30 @@ return { width = 30, side = "left" }, + git = { enable = true }, + renderer = { highlight_git = true }, + filters = { dotfiles = false, custom = { ".git" } }, + update_cwd = true, + update_focused_file = { enable = true } }) - -- Leader + e : Ouvrir/fermer l'explorateur de fichiers + -- Ouvrir/fermer l'explorateur de fichiers vim.keymap.set("n", "e", ":NvimTreeToggle", { desc = "Toggle file explorer", noremap = true, diff --git a/lua/plugins/nvim-treesitter.lua b/lua/plugins/nvim-treesitter.lua new file mode 100644 index 0000000..187b286 --- /dev/null +++ b/lua/plugins/nvim-treesitter.lua @@ -0,0 +1,73 @@ +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 +} diff --git a/lua/plugins/telescope.lua b/lua/plugins/telescope.lua index b63442e..55148b7 100644 --- a/lua/plugins/telescope.lua +++ b/lua/plugins/telescope.lua @@ -1,8 +1,10 @@ return { "nvim-telescope/telescope.nvim", + dependencies = { "nvim-lua/plenary.nvim", }, + config = function() local telescope = require("telescope") local telescope_builtin = require("telescope.builtin") @@ -14,14 +16,14 @@ return { } }) - -- Leader + f : Ouvrir la recherche de fichiers + -- Ouvrir la recherche de fichiers vim.keymap.set("n", "f", telescope_builtin.find_files, { desc = "Find files", noremap = true, silent = true }) - -- Leader + g : Ouvrir la recherche textuelle + -- Ouvrir la recherche textuelle vim.keymap.set("n", "g", telescope_builtin.live_grep, { desc = "Live grep", noremap = true,