From 9ff02b60e770235078c44a80f36a46883e04d5bf Mon Sep 17 00:00:00 2001 From: Andrew Lee Date: Thu, 27 Mar 2025 21:43:21 -0600 Subject: [PATCH] upgrade to astronvim v5 --- dot_config/nvim/lua/community.lua | 61 ++++++++++----------- dot_config/nvim/lua/lazy_setup.lua | 3 +- dot_config/nvim/lua/plugins/astrocore.lua | 63 ++++++++-------------- dot_config/nvim/lua/plugins/astrolsp.lua | 61 +++++++++------------ dot_config/nvim/lua/plugins/astroui.lua | 4 +- dot_config/nvim/lua/plugins/mason.lua | 55 ++++++++----------- dot_config/nvim/lua/plugins/none-ls.lua | 14 +++-- dot_config/nvim/lua/plugins/treesitter.lua | 11 ++-- dot_config/nvim/lua/plugins/user.lua | 41 +++++++------- 9 files changed, 139 insertions(+), 174 deletions(-) diff --git a/dot_config/nvim/lua/community.lua b/dot_config/nvim/lua/community.lua index 4a3e444..da18cc9 100644 --- a/dot_config/nvim/lua/community.lua +++ b/dot_config/nvim/lua/community.lua @@ -9,33 +9,30 @@ return { -- import/override with your plugins folder { import = "astrocommunity.colorscheme.catppuccin" }, - -- { import = "astrocommunity.editing-support.yanky-nvim" }, { import = "astrocommunity.diagnostics.trouble-nvim" }, { import = "astrocommunity.editing-support.todo-comments-nvim" }, - { import = "astrocommunity.editing-support.multicursors-nvim" }, + -- { import = "astrocommunity.editing-support.multicursors-nvim" }, { import = "astrocommunity.editing-support.rainbow-delimiters-nvim" }, - -- { import = "astrocommunity.lsp.lsp-signature-nvim" }, - { import = "astrocommunity.lsp.inc-rename-nvim" }, + -- { import = "astrocommunity.lsp.inc-rename-nvim" }, { import = "astrocommunity.markdown-and-latex.glow-nvim" }, - -- { import = "astrocommunity.motion.flash-nvim" }, + { import = "astrocommunity.recipes.vscode" }, { import = "astrocommunity.scrolling.mini-animate" }, { import = "astrocommunity.search.grug-far-nvim" }, { import = "astrocommunity.test.neotest" }, - { import = "astrocommunity.utility.noice-nvim" }, - -- { import = "astrocommunity.workflow.hardtime-nvim" }, + -- { import = "astrocommunity.utility.noice-nvim" }, { import = "astrocommunity.motion.nvim-surround" }, { "kylechui/nvim-surround", opts = { keymaps = { - normal = "sa", + normal = "sa", normal_cur = false, normal_line = false, normal_cur_line = false, - visual = "s", - visual_line = "S", - delete = "sd", - change = "sr", + visual = "s", + visual_line = "S", + delete = "sd", + change = "sr", }, aliases = { ["i"] = "]", -- Index @@ -60,24 +57,24 @@ return { }, }, }, - { - "folke/noice.nvim", - opts = { - routes = { - { - filter = { - event = "msg_show", - any = { - { find = "%d+L, %d+B" }, - { find = "; after #%d+" }, - { find = "; before #%d+" }, - { find = "%d fewer lines" }, - { find = "%d more lines" }, - }, - }, - opts = { skip = true }, - }, - }, - }, - }, + -- { + -- "folke/noice.nvim", + -- opts = { + -- routes = { + -- { + -- filter = { + -- event = "msg_show", + -- any = { + -- { find = "%d+L, %d+B" }, + -- { find = "; after #%d+" }, + -- { find = "; before #%d+" }, + -- { find = "%d fewer lines" }, + -- { find = "%d more lines" }, + -- }, + -- }, + -- opts = { skip = true }, + -- }, + -- }, + -- }, + -- }, } diff --git a/dot_config/nvim/lua/lazy_setup.lua b/dot_config/nvim/lua/lazy_setup.lua index cca2306..798e0d5 100644 --- a/dot_config/nvim/lua/lazy_setup.lua +++ b/dot_config/nvim/lua/lazy_setup.lua @@ -1,13 +1,14 @@ require("lazy").setup({ { "AstroNvim/AstroNvim", - version = "^4", -- Remove version tracking to elect for nighly AstroNvim + version = "^5", -- Remove version tracking to elect for nighly 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 maplocalleader = ",", -- This ensures the localleader key must be configured before Lazy is set up icons_enabled = true, -- Set to false to disable icons (if no Nerd Font is available) pin_plugins = nil, -- Default will pin plugins when tracking `version` of AstroNvim, set to true/false to override + update_notifications = true, -- Enable/disable notification about running `:Lazy update` twice to update pinned plugins }, }, { import = "community" }, diff --git a/dot_config/nvim/lua/plugins/astrocore.lua b/dot_config/nvim/lua/plugins/astrocore.lua index 3834335..f786291 100644 --- a/dot_config/nvim/lua/plugins/astrocore.lua +++ b/dot_config/nvim/lua/plugins/astrocore.lua @@ -1,3 +1,5 @@ +if true then return {} end -- WARN: REMOVE THIS LINE TO ACTIVATE THIS FILE + -- AstroCore provides a central place to modify mappings, vim options, autocommands, and more! -- Configuration documentation can be found with `:h astrocore` -- NOTE: We highly recommend setting up the Lua Language Server (`:LspInstall lua_ls`) @@ -10,12 +12,12 @@ return { opts = { -- Configure core features of AstroNvim features = { - large_buf = { size = 1024 * 500, lines = 10000 }, -- set global limits for large files for disabling features like treesitter - autopairs = true, -- enable autopairs at start - cmp = true, -- enable completion at start - diagnostics_mode = 3, -- diagnostic mode on start (0 = off, 1 = no signs/virtual text, 2 = no virtual text, 3 = on) - highlighturl = true, -- highlight URLs at start - notifications = true, -- enable notifications at start + large_buf = { size = 1024 * 256, lines = 10000 }, -- set global limits for large files for disabling features like treesitter + autopairs = true, -- enable autopairs at start + cmp = true, -- enable completion at start + diagnostics = { virtual_text = true, virtual_lines = false }, -- diagnostic settings on startup + highlighturl = true, -- highlight URLs at start + notifications = true, -- enable notifications at start }, -- Diagnostics configuration (for vim.diagnostics.config({...})) when diagnostics are on diagnostics = { @@ -24,14 +26,14 @@ return { }, -- vim options can be configured here options = { - opt = { -- vim.opt. + opt = { -- vim.opt. relativenumber = true, -- sets vim.opt.relativenumber - number = true, -- sets vim.opt.number - spell = false, -- sets vim.opt.spell - signcolumn = "auto", -- sets vim.opt.signcolumn to auto - wrap = false, -- sets vim.opt.wrap + number = true, -- sets vim.opt.number + spell = false, -- sets vim.opt.spell + signcolumn = "yes", -- sets vim.opt.signcolumn to yes + wrap = false, -- sets vim.opt.wrap }, - g = { -- vim.g. + g = { -- vim.g. -- configure global vim variables (vim.g) -- NOTE: `mapleader` and `maplocalleader` must be set in the AstroNvim opts or before `lazy.setup` -- This can be found in the `lua/lazy_setup.lua` file @@ -44,45 +46,26 @@ return { n = { -- second key is the lefthand side of the map - -- navigate buffer tabs with `H` and `L` - -- L = { - -- function() require("astrocore.buffer").nav(vim.v.count > 0 and vim.v.count or 1) end, - -- desc = "Next buffer", - -- }, - -- H = { - -- function() require("astrocore.buffer").nav(-(vim.v.count > 0 and vim.v.count or 1)) end, - -- desc = "Previous buffer", - -- }, - [""] = { "", desc = "Scroll half down" }, - [""] = { "", desc = "Scroll half up" }, + -- 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" }, - ["sw"] = { "saiw", desc = "Surround word", remap = true }, - ["sW"] = { "saiW", desc = "Surround Word", remap = true }, - [""] = { - function() - require("notify").dismiss({ silent = true, pending = true }) - end, - desc = "Dismiss notifications", - }, -- mappings seen under group name "Buffer" - ["bn"] = { "tabnew", desc = "New tab" }, - ["bD"] = { + ["bd"] = { function() require("astroui.status.heirline").buffer_picker( function(bufnr) require("astrocore.buffer").close(bufnr) end ) end, - desc = "Pick to close", + desc = "Close buffer from tabline", }, + -- 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" }, - -- quick save - -- [""] = { ":w!", desc = "Save File" }, -- change description but the same command - }, - t = { + -- ["b"] = { desc = "Buffers" }, + -- setting a mapping to false will disable it - -- [""] = false, + -- [""] = false, }, }, }, diff --git a/dot_config/nvim/lua/plugins/astrolsp.lua b/dot_config/nvim/lua/plugins/astrolsp.lua index 07b7e51..720b9d3 100644 --- a/dot_config/nvim/lua/plugins/astrolsp.lua +++ b/dot_config/nvim/lua/plugins/astrolsp.lua @@ -1,3 +1,5 @@ +if true then return {} end -- WARN: REMOVE THIS LINE TO ACTIVATE THIS FILE + -- AstroLSP allows you to customize the features in AstroNvim's LSP configuration engine -- Configuration documentation can be found with `:h astrolsp` -- NOTE: We highly recommend setting up the Lua Language Server (`:LspInstall lua_ls`) @@ -10,16 +12,15 @@ return { opts = { -- Configuration table of features provided by AstroLSP features = { - autoformat = true, -- enable or disable auto formatting on start - codelens = true, -- enable/disable codelens refresh on start - inlay_hints = false, -- enable/disable inlay hints on start + codelens = true, -- enable/disable codelens refresh on start + inlay_hints = false, -- enable/disable inlay hints on start semantic_tokens = true, -- enable/disable semantic token highlighting }, -- customize lsp formatting options formatting = { -- control auto formatting on save format_on_save = { - enabled = true, -- enable or disable format on save globally + enabled = true, -- enable or disable format on save globally allow_filetypes = { -- enable format on save for specified filetypes only -- "go", }, @@ -39,23 +40,11 @@ return { -- enable servers that you already have installed without mason servers = { -- "pyright" - "zls", }, -- customize language server configuration options passed to `lspconfig` ---@diagnostic disable: missing-fields config = { -- clangd = { capabilities = { offsetEncoding = "utf-8" } }, - zls = { - cmd = { "zls" }, - filetypes = { "zig" }, - }, - clangd = { - cmd = { - "clangd", - "--offset-encoding=utf-16", - }, - filetypes = { "c", "cpp", "objc", "objcpp" }, - }, }, -- customize how language servers are attached handlers = { @@ -69,43 +58,41 @@ return { -- Configure buffer local auto commands to add when attaching a language server autocmds = { -- first key is the `augroup` to add the auto commands to (:h augroup) - lsp_document_highlight = { + lsp_codelens_refresh = { -- Optional condition to create/delete auto command group -- can either be a string of a client capability or a function of `fun(client, bufnr): boolean` -- condition will be resolved for each client on each execution and if it ever fails for all clients, -- the auto commands will be deleted for that buffer - cond = "textDocument/documentHighlight", + cond = "textDocument/codeLens", -- cond = function(client, bufnr) return client.name == "lua_ls" end, -- list of auto commands to set { -- events to trigger - event = { "CursorHold", "CursorHoldI" }, + event = { "InsertLeave", "BufEnter" }, -- the rest of the autocmd options (:h nvim_create_autocmd) - desc = "Document Highlighting", - callback = function() vim.lsp.buf.document_highlight() end, - }, - { - event = { "CursorMoved", "CursorMovedI", "BufLeave" }, - desc = "Document Highlighting Clear", - callback = function() vim.lsp.buf.clear_references() end, + desc = "Refresh codelens (buffer)", + callback = function(args) + if require("astrolsp").config.features.codelens then vim.lsp.codelens.refresh { bufnr = args.buf } end + end, }, }, }, -- mappings to be set up on attaching of a language server mappings = { n = { - gl = { function() vim.diagnostic.open_float() end, desc = "Hover diagnostics" }, -- a `cond` key can provided as the string of a server capability to be required to attach, or a function with `client` and `bufnr` parameters from the `on_attach` that returns a boolean - -- gD = { - -- function() vim.lsp.buf.declaration() end, - -- desc = "Declaration of current symbol", - -- cond = "textDocument/declaration", - -- }, - -- ["uY"] = { - -- function() require("astrolsp.toggles").buffer_semantic_tokens() end, - -- desc = "Toggle LSP semantic highlight (buffer)", - -- cond = function(client) return client.server_capabilities.semanticTokensProvider and vim.lsp.semantic_tokens end, - -- }, + gD = { + function() vim.lsp.buf.declaration() end, + desc = "Declaration of current symbol", + cond = "textDocument/declaration", + }, + ["uY"] = { + 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 + end, + }, }, }, -- A custom `on_attach` function to be run after the default `on_attach` function diff --git a/dot_config/nvim/lua/plugins/astroui.lua b/dot_config/nvim/lua/plugins/astroui.lua index 9a64362..737a2fb 100644 --- a/dot_config/nvim/lua/plugins/astroui.lua +++ b/dot_config/nvim/lua/plugins/astroui.lua @@ -1,3 +1,5 @@ +if true then return {} end -- WARN: REMOVE THIS LINE TO ACTIVATE THIS FILE + -- AstroUI provides the basis for configuring the AstroNvim User Interface -- Configuration documentation can be found with `:h astroui` -- NOTE: We highly recommend setting up the Lua Language Server (`:LspInstall lua_ls`) @@ -15,7 +17,7 @@ return { init = { -- this table overrides highlights in all themes -- Normal = { bg = "#000000" }, }, - astrotheme = { -- a table of overrides/changes when applying the astrotheme theme + astrodark = { -- a table of overrides/changes when applying the astrotheme theme -- Normal = { bg = "#000000" }, }, }, diff --git a/dot_config/nvim/lua/plugins/mason.lua b/dot_config/nvim/lua/plugins/mason.lua index 74db0e6..2d79b5f 100644 --- a/dot_config/nvim/lua/plugins/mason.lua +++ b/dot_config/nvim/lua/plugins/mason.lua @@ -1,41 +1,28 @@ --- Customize Mason plugins +if true then return {} end -- WARN: REMOVE THIS LINE TO ACTIVATE THIS FILE + +-- Customize Mason ---@type LazySpec return { - -- use mason-lspconfig to configure LSP installations + -- use mason-tool-installer for automatically installing Mason packages { - "williamboman/mason-lspconfig.nvim", - -- overrides `require("mason-lspconfig").setup(...)` - opts = function(_, opts) - -- add more things to the ensure_installed table protecting against community packs modifying it - opts.ensure_installed = require("astrocore").list_insert_unique(opts.ensure_installed, { - "lua_ls", - -- add more arguments for adding more language servers - }) - end, - }, - -- use mason-null-ls to configure Formatters/Linter installation for null-ls sources - { - "jay-babu/mason-null-ls.nvim", - -- overrides `require("mason-null-ls").setup(...)` - opts = function(_, opts) - -- add more things to the ensure_installed table protecting against community packs modifying it - opts.ensure_installed = require("astrocore").list_insert_unique(opts.ensure_installed, { - "prettier", + "WhoIsSethDaniel/mason-tool-installer.nvim", + -- overrides `require("mason-tool-installer").setup(...)` + opts = { + -- Make sure to use the names found in `:Mason` + ensure_installed = { + -- install language servers + "lua-language-server", + + -- install formatters "stylua", - -- add more arguments for adding more null-ls sources - }) - end, - }, - { - "jay-babu/mason-nvim-dap.nvim", - -- overrides `require("mason-nvim-dap").setup(...)` - opts = function(_, opts) - -- add more things to the ensure_installed table protecting against community packs modifying it - opts.ensure_installed = require("astrocore").list_insert_unique(opts.ensure_installed, { - "python", - -- add more arguments for adding more debuggers - }) - end, + + -- install debuggers + "debugpy", + + -- install any other package + "tree-sitter-cli", + }, + }, }, } diff --git a/dot_config/nvim/lua/plugins/none-ls.lua b/dot_config/nvim/lua/plugins/none-ls.lua index 727603f..2b0ed18 100644 --- a/dot_config/nvim/lua/plugins/none-ls.lua +++ b/dot_config/nvim/lua/plugins/none-ls.lua @@ -1,20 +1,24 @@ +if true then return {} end -- WARN: REMOVE THIS LINE TO ACTIVATE THIS FILE + -- Customize None-ls sources ---@type LazySpec return { "nvimtools/none-ls.nvim", - opts = function(_, config) - -- config variable is the default configuration table for the setup function call + opts = function(_, opts) + -- opts variable is the default configuration table for the setup function call -- local null_ls = require "null-ls" -- Check supported formatters and linters -- https://github.com/nvimtools/none-ls.nvim/tree/main/lua/null-ls/builtins/formatting -- https://github.com/nvimtools/none-ls.nvim/tree/main/lua/null-ls/builtins/diagnostics - config.sources = { + + -- Only insert new sources, do not replace the existing ones + -- (If you wish to replace, use `opts.sources = {}` instead of the `list_insert_unique` function) + opts.sources = require("astrocore").list_insert_unique(opts.sources, { -- Set a formatter -- null_ls.builtins.formatting.stylua, -- null_ls.builtins.formatting.prettier, - } - return config -- return final config table + }) end, } diff --git a/dot_config/nvim/lua/plugins/treesitter.lua b/dot_config/nvim/lua/plugins/treesitter.lua index 5180405..94436aa 100644 --- a/dot_config/nvim/lua/plugins/treesitter.lua +++ b/dot_config/nvim/lua/plugins/treesitter.lua @@ -1,14 +1,15 @@ +if true then return {} end -- WARN: REMOVE THIS LINE TO ACTIVATE THIS FILE + -- Customize Treesitter ---@type LazySpec return { "nvim-treesitter/nvim-treesitter", - opts = function(_, opts) - -- add more things to the ensure_installed table protecting against community packs modifying it - opts.ensure_installed = require("astrocore").list_insert_unique(opts.ensure_installed, { + opts = { + ensure_installed = { "lua", "vim", -- add more arguments for adding more treesitter parsers - }) - end, + }, + }, } diff --git a/dot_config/nvim/lua/plugins/user.lua b/dot_config/nvim/lua/plugins/user.lua index 121089e..b7de6df 100644 --- a/dot_config/nvim/lua/plugins/user.lua +++ b/dot_config/nvim/lua/plugins/user.lua @@ -1,6 +1,7 @@ if true then return {} end -- WARN: REMOVE THIS LINE TO ACTIVATE THIS FILE -- You can also add or configure plugins by creating files in this `plugins/` folder +-- PLEASE REMOVE THE EXAMPLES YOU HAVE NO INTEREST IN BEFORE ENABLING THIS FILE -- Here are some examples: ---@type LazySpec @@ -17,26 +18,28 @@ return { -- == Examples of Overriding Plugins == - -- customize alpha options + -- customize dashboard options { - "goolord/alpha-nvim", - opts = function(_, opts) - -- customize the dashboard header - opts.section.header.val = { - " █████ ███████ ████████ ██████ ██████", - "██ ██ ██ ██ ██ ██ ██ ██", - "███████ ███████ ██ ██████ ██ ██", - "██ ██ ██ ██ ██ ██ ██ ██", - "██ ██ ███████ ██ ██ ██ ██████", - " ", - " ███  ██ ██  ██ ██ ███  ███", - " ████  ██ ██  ██ ██ ████  ████", - " ██ ██  ██ ██  ██ ██ ██ ████ ██", - " ██  ██ ██  ██  ██  ██ ██  ██  ██", - " ██   ████   ████   ██ ██      ██", - } - return opts - end, + "folke/snacks.nvim", + opts = { + dashboard = { + preset = { + header = table.concat({ + " █████ ███████ ████████ ██████ ██████ ", + "██ ██ ██ ██ ██ ██ ██ ██", + "███████ ███████ ██ ██████ ██ ██", + "██ ██ ██ ██ ██ ██ ██ ██", + "██ ██ ███████ ██ ██ ██ ██████ ", + "", + "███  ██ ██  ██ ██ ███  ███", + "████  ██ ██  ██ ██ ████  ████", + "██ ██  ██ ██  ██ ██ ██ ████ ██", + "██  ██ ██  ██  ██  ██ ██  ██  ██", + "██   ████   ████   ██ ██      ██", + }, "\n"), + }, + }, + }, }, -- You can disable default plugins as follows: