From 6e029594408bec8ea052e82a43c054f063415ceb Mon Sep 17 00:00:00 2001 From: Xavier Logerais Date: Wed, 15 Jul 2026 20:27:01 +0200 Subject: [PATCH] feat: Upgrade to AstroNvim v6 --- README.md | 2 +- init.lua | 10 +++- lua/community.lua | 24 ++++----- lua/lazy_setup.lua | 16 +++--- lua/plugins/astrocore.lua | 108 ++++++++++++++++++------------------- lua/plugins/astrolsp.lua | 19 ++++--- lua/plugins/treesitter.lua | 19 +++++-- lua/plugins/user.lua | 4 +- lua/polish.lua | 10 +--- 9 files changed, 108 insertions(+), 104 deletions(-) diff --git a/README.md b/README.md index 71d48de..4488bde 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # AstroNvim Template -**NOTE:** This is for AstroNvim v5+ +**NOTE:** This is for AstroNvim v6+ A template for getting started with [AstroNvim](https://github.com/AstroNvim/AstroNvim) diff --git a/init.lua b/init.lua index 2ce1cdd..424e48d 100644 --- a/init.lua +++ b/init.lua @@ -1,10 +1,18 @@ -- This file simply bootstraps the installation of Lazy.nvim and then calls other files for execution -- This file doesn't necessarily need to be touched, BE CAUTIOUS editing this file and proceed at your own risk. local lazypath = vim.env.LAZY or vim.fn.stdpath "data" .. "/lazy/lazy.nvim" + if not (vim.env.LAZY or (vim.uv or vim.loop).fs_stat(lazypath)) then -- stylua: ignore - vim.fn.system({ "git", "clone", "--filter=blob:none", "https://github.com/folke/lazy.nvim.git", "--branch=stable", lazypath }) + local result = vim.fn.system({ "git", "clone", "--filter=blob:none", "https://github.com/folke/lazy.nvim.git", "--branch=stable", lazypath }) + if vim.v.shell_error ~= 0 then + -- stylua: ignore + vim.api.nvim_echo({ { ("Error cloning lazy.nvim:\n%s\n"):format(result), "ErrorMsg" }, { "Press any key to exit...", "MoreMsg" } }, true, {}) + vim.fn.getchar() + vim.cmd.quit() + end end + vim.opt.rtp:prepend(lazypath) -- validate that lazy is available diff --git a/lua/community.lua b/lua/community.lua index 76de7d2..9036400 100644 --- a/lua/community.lua +++ b/lua/community.lua @@ -54,7 +54,8 @@ return { -- { import = "astrocommunity.completion.copilot-lua-cmp" }, -- AI - { import = "astrocommunity.ai.minuet-ai-nvim" }, + -- { import = "astrocommunity.ai.copilotchat-nvim" }, + -- { import = "astrocommunity.ai.minuet-ai-nvim" }, -- Telescope { import = "astrocommunity.terminal-integration.toggleterm-manager-nvim" }, -- A Telescope extension to manage Toggleterm's terminals in NeoVim @@ -68,15 +69,7 @@ return { { import = "astrocommunity.editing-support.nvim-devdocs" }, { import = "astrocommunity.git.diffview-nvim" }, { import = "astrocommunity.markdown-and-latex.render-markdown-nvim" }, - -- { import = "astrocommunity.markdown-and-latex.markview-nvim" }, - { import = "astrocommunity.programming-language-support.kulala-nvim" }, -- A minimal HTTP-client interface for Neovim - - -- Disabled - - -- { import = "astrocommunity.bars-and-lines.smartcolumn-nvim" }, -- display a column when text width exceed defined limit - -- { import = "astrocommunity.editing-support.chatgpt-nvim" }, - -- { import = "astrocommunity.programming-language-support.rest-nvim" }, - -- { import = "astrocommunity.project.project-nvim" }, + -- { import = "astrocommunity.markdown-and-latex.markview-nvim" }, -- Alternative to render-markdown-nvim -- Individual plugins (colorschemes) { import = "astrocommunity.colorscheme.vscode-nvim" }, @@ -89,6 +82,13 @@ return { { import = "astrocommunity.colorscheme.tokyonight-nvim" }, { import = "astrocommunity.colorscheme.onedarkpro-nvim" }, + -- Disabled + + -- { import = "astrocommunity.bars-and-lines.smartcolumn-nvim" }, -- display a column when text width exceed defined limit + -- { import = "astrocommunity.editing-support.chatgpt-nvim" }, + -- { import = "astrocommunity.programming-language-support.rest-nvim" }, + -- { import = "astrocommunity.project.project-nvim" }, + -- Individual plugins customization -- { -- "nvim-treesitter/nvim-treesitter", @@ -100,8 +100,4 @@ return { -- end -- end, -- }, - - -- Now provided by core - -- { import = "astrocommunity.bars-and-lines.vim-illuminate" }, -- highlight other uses of the word under cursor - -- { import = "astrocommunity.editing-support.todo-comments-nvim" }, } diff --git a/lua/lazy_setup.lua b/lua/lazy_setup.lua index 159a9a2..d492b37 100644 --- a/lua/lazy_setup.lua +++ b/lua/lazy_setup.lua @@ -1,7 +1,7 @@ require("lazy").setup({ { "AstroNvim/AstroNvim", - version = "^5", -- Remove version tracking to elect for nightly AstroNvim + version = "^6", -- Remove version tracking to elect for nightly AstroNvim import = "astronvim.plugins", opts = { -- AstroNvim options must be set here with the `import` key mapleader = " ", -- This ensures the leader key must be configured before Lazy is set up @@ -20,13 +20,13 @@ require("lazy").setup({ performance = { rtp = { -- disable some rtp plugins, add more to your liking - -- disabled_plugins = { - -- "gzip", - -- "netrwPlugin", - -- "tarPlugin", - -- "tohtml", - -- "zipPlugin", - -- }, + disabled_plugins = { + -- "gzip", + -- "netrwPlugin", + -- "tarPlugin", + -- "zipPlugin", + "tohtml", + }, }, }, } --[[@as LazyConfig]]) diff --git a/lua/plugins/astrocore.lua b/lua/plugins/astrocore.lua index bc69919..4065a1b 100644 --- a/lua/plugins/astrocore.lua +++ b/lua/plugins/astrocore.lua @@ -35,45 +35,6 @@ return { [".*/etc/foo/.*"] = "fooscript", }, }, - -- Commands - commands = { - CleanYamlSpaces = { - function() - if vim.bo.filetype == 'yaml' or vim.bo.filetype == 'yml' then - local cursor_pos = vim.api.nvim_win_get_cursor(0) - vim.cmd([[%s/\s\+$//e]]) - vim.api.nvim_win_set_cursor(0, cursor_pos) - print("Espaces en fin de ligne supprimés") - else - print("Cette commande ne fonctionne que sur les fichiers YAML") - end - end, - desc = "Nettoie les espaces en fin de ligne dans les fichiers YAML", - }, - }, - -- Autocmd - autocmds = { - yaml_trailing_spaces = { - { - event = { "BufRead", "BufNewFile" }, - pattern = { "*.yaml", "*.yml" }, - callback = function() - vim.fn.matchadd("TrailingWhiteSpace", "\\s\\+$") - end, - desc = "Surligne les espaces en fin de ligne dans les fichiers YAML", - }, - { - event = "BufWritePre", - pattern = { "*.yaml", "*.yml" }, - callback = function() - local cursor_pos = vim.api.nvim_win_get_cursor(0) - vim.cmd([[%s/\s\+$//e]]) - vim.api.nvim_win_set_cursor(0, cursor_pos) - end, - desc = "Nettoie les espaces en fin de ligne avant sauvegarde", - }, - }, - }, -- vim options can be configured here options = { opt = { -- vim.opt. @@ -90,30 +51,34 @@ return { -- This can be found in the `lua/lazy_setup.lua` file }, }, + -- Commands + commands = { + CleanYamlSpaces = { + function() + if vim.bo.filetype == "yaml" or vim.bo.filetype == "yml" then + local cursor_pos = vim.api.nvim_win_get_cursor(0) + vim.cmd [[%s/\s\+$//e]] + vim.api.nvim_win_set_cursor(0, cursor_pos) + print "Espaces en fin de ligne supprimés" + else + print "Cette commande ne fonctionne que sur les fichiers YAML" + end + end, + desc = "Nettoie les espaces en fin de ligne dans les fichiers YAML", + }, + }, -- Mappings can be configured through AstroCore as well. -- NOTE: keycodes follow the casing in the vimdocs. For example, `` must be capitalized mappings = { - + -- first key is the mode n = { - - -- tables with just a `desc` key will be registered with which-key if it's installed - -- this is useful for naming menus - -- ["b"] = { desc = "Buffers" }, - - -- setting a mapping to false will disable it - -- [""] = false, - - -- Visual selection of pasted text - ["gp"] = { "`[v`]", desc = "Visual selection of pasted text" }, + -- second key is the lefthand side of the map -- navigate buffer tabs ["]b"] = { function() require("astrocore.buffer").nav(vim.v.count1) end, desc = "Next buffer" }, ["[b"] = { function() require("astrocore.buffer").nav(-vim.v.count1) end, desc = "Previous buffer" }, -- mappings seen under group name "Buffer" - ["b"] = { desc = "Buffers" }, - ["bn"] = { function() require("astrocore.buffer").nav(vim.v.count1) end, desc = "Next buffer" }, - ["bp"] = { function() require("astrocore.buffer").nav(-vim.v.count1) end, desc = "Previous buffer" }, ["bd"] = { function() require("astroui.status.heirline").buffer_picker( @@ -122,11 +87,21 @@ return { end, desc = "Close buffer from tabline", }, - ["bp"] = { function() require("astrocore.buffer").nav(-vim.v.count1) end, desc = "Previous buffer" }, ["bn"] = { function() require("astrocore.buffer").nav(vim.v.count1) end, desc = "Next buffer" }, + ["bp"] = { function() require("astrocore.buffer").nav(-vim.v.count1) end, desc = "Previous buffer" }, + + -- tables with just a `desc` key will be registered with which-key if it's installed + -- this is useful for naming menus + ["b"] = { desc = "Buffers" }, + + -- setting a mapping to false will disable it + -- [""] = false, + + -- Visual selection of pasted text + ["gp"] = { "`[v`]", desc = "Visual selection of pasted text" }, -- Normal mode : Custom mappings - [""] = { "Neotree toggle", desc = "File Explorer" }, -- F26 corresponds to on my keyboard + [""] = { "Neotree toggle", desc = "File Explorer" }, [""] = { function() require("astrocore").toggle_term_cmd { cmd = "lazygit", direction = "float" } end, desc = "Lazygit terminal", @@ -138,7 +113,7 @@ return { }, -- Insert mode : Custom mappings i = { - [""] = { "Neotree toggle", desc = "File Explorer" }, -- F26 corresponds to on my keyboard + [""] = { "Neotree toggle", desc = "File Explorer" }, [""] = { function() require("astrocore").toggle_term_cmd { cmd = "lazygit", direction = "float" } end, desc = "Lazygit terminal", @@ -174,5 +149,26 @@ return { }, -- F28 corresponds to on my keyboard }, }, + -- Autocmd + autocmds = { + yaml_trailing_spaces = { + { + event = { "BufRead", "BufNewFile" }, + pattern = { "*.yaml", "*.yml" }, + callback = function() vim.fn.matchadd("TrailingWhiteSpace", "\\s\\+$") end, + desc = "Surligne les espaces en fin de ligne dans les fichiers YAML", + }, + { + event = "BufWritePre", + pattern = { "*.yaml", "*.yml" }, + callback = function() + local cursor_pos = vim.api.nvim_win_get_cursor(0) + vim.cmd [[%s/\s\+$//e]] + vim.api.nvim_win_set_cursor(0, cursor_pos) + end, + desc = "Nettoie les espaces en fin de ligne avant sauvegarde", + }, + }, + }, }, } diff --git a/lua/plugins/astrolsp.lua b/lua/plugins/astrolsp.lua index 720b9d3..b8b121f 100644 --- a/lua/plugins/astrolsp.lua +++ b/lua/plugins/astrolsp.lua @@ -41,19 +41,18 @@ return { servers = { -- "pyright" }, - -- customize language server configuration options passed to `lspconfig` - ---@diagnostic disable: missing-fields + -- customize language server configuration passed to `vim.lsp.config` + -- client specific configuration can also go in `lsp/` in your configuration root (see `:h lsp-config`) config = { - -- clangd = { capabilities = { offsetEncoding = "utf-8" } }, + -- ["*"] = { capabilities = {} }, -- modify default LSP client settings such as capabilities }, -- customize how language servers are attached handlers = { - -- a function without a key is simply the default handler, functions take two parameters, the server name and the configured options table for that server - -- function(server, opts) require("lspconfig")[server].setup(opts) end + -- a function with the key `*` modifies the default handler, functions takes the server name as the parameter + -- ["*"] = function(server) vim.lsp.enable(server) end - -- the key is the server that is being setup with `lspconfig` + -- the key is the server that is being setup with `vim.lsp.config` -- rust_analyzer = false, -- setting a handler to false will disable the set up of that language server - -- pyright = function(_, opts) require("lspconfig").pyright.setup(opts) end -- or a custom handler function can be passed }, -- Configure buffer local auto commands to add when attaching a language server autocmds = { @@ -72,7 +71,7 @@ return { -- the rest of the autocmd options (:h nvim_create_autocmd) desc = "Refresh codelens (buffer)", callback = function(args) - if require("astrolsp").config.features.codelens then vim.lsp.codelens.refresh { bufnr = args.buf } end + if require("astrolsp").config.features.codelens then vim.lsp.codelens.enable(true, { bufnr = args.buf }) end end, }, }, @@ -90,13 +89,13 @@ return { function() require("astrolsp.toggles").buffer_semantic_tokens() end, desc = "Toggle LSP semantic highlight (buffer)", cond = function(client) - return client.supports_method "textDocument/semanticTokens/full" and vim.lsp.semantic_tokens ~= nil + return client:supports_method "textDocument/semanticTokens/full" and vim.lsp.semantic_tokens ~= nil end, }, }, }, -- A custom `on_attach` function to be run after the default `on_attach` function - -- takes two parameters `client` and `bufnr` (`:h lspconfig-setup`) + -- takes two parameters `client` and `bufnr` (`:h lsp-attach`) on_attach = function(client, bufnr) -- this would disable semanticTokensProvider for all clients -- client.server_capabilities.semanticTokensProvider = nil diff --git a/lua/plugins/treesitter.lua b/lua/plugins/treesitter.lua index 94436aa..3a9afe9 100644 --- a/lua/plugins/treesitter.lua +++ b/lua/plugins/treesitter.lua @@ -1,15 +1,24 @@ if true then return {} end -- WARN: REMOVE THIS LINE TO ACTIVATE THIS FILE -- Customize Treesitter +-- -------------------- +-- Treesitter customizations are handled with AstroCore +-- as nvim-treesitter simply provides a download utility for parsers ---@type LazySpec return { - "nvim-treesitter/nvim-treesitter", + "AstroNvim/astrocore", + ---@type AstroCoreOpts opts = { - ensure_installed = { - "lua", - "vim", - -- add more arguments for adding more treesitter parsers + treesitter = { + highlight = true, -- enable/disable treesitter based highlighting + indent = true, -- enable/disable treesitter based indentation + auto_install = true, -- enable/disable automatic installation of detected languages + ensure_installed = { + "lua", + "vim", + -- add more arguments for adding more treesitter parsers + }, }, }, } diff --git a/lua/plugins/user.lua b/lua/plugins/user.lua index b7de6df..d332627 100644 --- a/lua/plugins/user.lua +++ b/lua/plugins/user.lua @@ -49,10 +49,12 @@ return { { "L3MON4D3/LuaSnip", config = function(plugin, opts) - require "astronvim.plugins.configs.luasnip"(plugin, opts) -- include the default astronvim config that calls the setup call -- add more custom luasnip configuration such as filetype extend or custom snippets local luasnip = require "luasnip" luasnip.filetype_extend("javascript", { "javascriptreact" }) + + -- include the default astronvim config that calls the setup call + require "astronvim.plugins.configs.luasnip"(plugin, opts) end, }, diff --git a/lua/polish.lua b/lua/polish.lua index 6b68109..642719f 100644 --- a/lua/polish.lua +++ b/lua/polish.lua @@ -1,11 +1,5 @@ +if true then return end -- WARN: REMOVE THIS LINE TO ACTIVATE THIS FILE + -- This will run last in the setup process. -- This is just pure lua so anything that doesn't -- fit in the normal config locations above can go here - --- Needed for python3 through mise --- Locate python3 using PATH -local python_path = vim.fn.exepath "python3" -if python_path == nil or python_path == "" then -else - vim.g.python3_host_prog = python_path -end -- 2.43.0