From 5dae91a387586c8455e5953845113968a5687493 Mon Sep 17 00:00:00 2001 From: Micah Halter Date: Tue, 25 Jul 2023 12:00:48 -0400 Subject: [PATCH] feat!: Move to AstroNvim v4 distributed through lazy.nvim --- .github/README.md | 10 +-- highlights/duskfox.lua | 3 - highlights/init.lua | 3 - init.lua | 89 ++----------------------- lua/config/lazy.lua | 44 ++++++++++++ lua/config/options.lua | 10 +++ lua/config/polish.lua | 16 +++++ lua/plugins/astrocore.lua | 42 ++++++++++++ lua/plugins/astrolsp.lua | 39 +++++++++++ lua/plugins/astroui.lua | 14 ++++ {plugins => lua/plugins}/core.lua | 0 {plugins => lua/plugins}/mason.lua | 6 +- {plugins => lua/plugins}/null-ls.lua | 0 {plugins => lua/plugins}/treesitter.lua | 2 +- {plugins => lua/plugins}/user.lua | 0 mappings.lua | 28 -------- options.lua | 30 --------- plugins/community.lua | 9 --- 18 files changed, 176 insertions(+), 169 deletions(-) delete mode 100644 highlights/duskfox.lua delete mode 100644 highlights/init.lua create mode 100644 lua/config/lazy.lua create mode 100644 lua/config/options.lua create mode 100644 lua/config/polish.lua create mode 100644 lua/plugins/astrocore.lua create mode 100644 lua/plugins/astrolsp.lua create mode 100644 lua/plugins/astroui.lua rename {plugins => lua/plugins}/core.lua (100%) rename {plugins => lua/plugins}/mason.lua (85%) rename {plugins => lua/plugins}/null-ls.lua (100%) rename {plugins => lua/plugins}/treesitter.lua (78%) rename {plugins => lua/plugins}/user.lua (100%) delete mode 100644 mappings.lua delete mode 100644 options.lua delete mode 100644 plugins/community.lua diff --git a/.github/README.md b/.github/README.md index e6c589a..69e701a 100644 --- a/.github/README.md +++ b/.github/README.md @@ -9,12 +9,8 @@ A user configuration template for [AstroNvim](https://github.com/AstroNvim/Astro ```shell mv ~/.config/nvim ~/.config/nvim.bak mv ~/.local/share/nvim ~/.local/share/nvim.bak -``` - -#### Clone AstroNvim - -```shell -git clone https://github.com/AstroNvim/AstroNvim ~/.config/nvim +mv ~/.local/state/nvim ~/.local/state/nvim.bak +mv ~/.cache/nvim ~/.cache/nvim.bak ``` #### Create a new user repository from this template @@ -26,7 +22,7 @@ You can also just clone this repository directly if you do not want to track you #### Clone the repository ```shell -git clone https://github.com// ~/.config/nvim/lua/user +git clone https://github.com// ~/.config/nvim ``` #### Start Neovim diff --git a/highlights/duskfox.lua b/highlights/duskfox.lua deleted file mode 100644 index 31318ee..0000000 --- a/highlights/duskfox.lua +++ /dev/null @@ -1,3 +0,0 @@ -return { -- a table of overrides/changes to the duskfox theme - Normal = { bg = "#000000" }, -} diff --git a/highlights/init.lua b/highlights/init.lua deleted file mode 100644 index f7e055b..0000000 --- a/highlights/init.lua +++ /dev/null @@ -1,3 +0,0 @@ -return { -- this table overrides highlights in all themes - -- Normal = { bg = "#000000" }, -} diff --git a/init.lua b/init.lua index fb34405..adc5575 100644 --- a/init.lua +++ b/init.lua @@ -1,85 +1,4 @@ -return { - -- Configure AstroNvim updates - updater = { - remote = "origin", -- remote to use - channel = "stable", -- "stable" or "nightly" - version = "latest", -- "latest", tag name, or regex search like "v1.*" to only do updates before v2 (STABLE ONLY) - branch = "nightly", -- branch name (NIGHTLY ONLY) - commit = nil, -- commit hash (NIGHTLY ONLY) - pin_plugins = nil, -- nil, true, false (nil will pin plugins on stable only) - skip_prompts = false, -- skip prompts about breaking changes - show_changelog = true, -- show the changelog after performing an update - auto_quit = false, -- automatically quit the current session after a successful update - remotes = { -- easily add new remotes to track - -- ["remote_name"] = "https://remote_url.come/repo.git", -- full remote url - -- ["remote2"] = "github_user/repo", -- GitHub user/repo shortcut, - -- ["remote3"] = "github_user", -- GitHub user assume AstroNvim fork - }, - }, - - -- Set colorscheme to use - colorscheme = "astrodark", - - -- Diagnostics configuration (for vim.diagnostics.config({...})) when diagnostics are on - diagnostics = { - virtual_text = true, - underline = true, - }, - - lsp = { - -- customize lsp formatting options - formatting = { - -- control auto formatting on save - format_on_save = { - enabled = true, -- enable or disable format on save globally - allow_filetypes = { -- enable format on save for specified filetypes only - -- "go", - }, - ignore_filetypes = { -- disable format on save for specified filetypes - -- "python", - }, - }, - disabled = { -- disable formatting capabilities for the listed language servers - -- disable lua_ls formatting capability if you want to use StyLua to format your lua code - -- "lua_ls", - }, - timeout_ms = 1000, -- default format timeout - -- filter = function(client) -- fully override the default formatting function - -- return true - -- end - }, - -- enable servers that you already have installed without mason - servers = { - -- "pyright" - }, - }, - - -- Configure require("lazy").setup() options - lazy = { - defaults = { lazy = true }, - performance = { - rtp = { - -- customize default disabled vim plugins - disabled_plugins = { "tohtml", "gzip", "matchit", "zipPlugin", "netrwPlugin", "tarPlugin" }, - }, - }, - }, - - -- This function is run last and is a good place to configuring - -- augroups/autocommands and custom filetypes also this just pure lua so - -- anything that doesn't fit in the normal config locations above can go here - polish = function() - -- Set up custom filetypes - -- vim.filetype.add { - -- extension = { - -- foo = "fooscript", - -- }, - -- filename = { - -- ["Foofile"] = "fooscript", - -- }, - -- pattern = { - -- ["~/%.config/foo/.*"] = "fooscript", - -- }, - -- } - end, -} +-- bootstrap lazy.nvim, AstroNvim, and user plugins +require "config.lazy" +-- run polish file at the very end +pcall(require, "config.polish") diff --git a/lua/config/lazy.lua b/lua/config/lazy.lua new file mode 100644 index 0000000..e7344d2 --- /dev/null +++ b/lua/config/lazy.lua @@ -0,0 +1,44 @@ +local lazypath = vim.fn.stdpath "data" .. "/lazy/lazy.nvim" +if not 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 }) +end +vim.opt.rtp:prepend(vim.env.LAZY or lazypath) + +-- TODO: set to true on release +local USE_STABLE = false -- use stable releases of AstroNvim + +local spec = { + -- TODO: remove branch v4 on release + { "AstroNvim/AstroNvim", branch = "v4", version = USE_STABLE and "*" or nil, import = "astronvim.plugins" }, +} +if USE_STABLE then table.insert(spec, { import = "astronvim.lazy_snapshot" }) end -- pin plugins to known stable versions/commits + +require("lazy").setup { + spec = vim.list_extend(spec, { + -- AstroCommunity import any community modules here + -- { "AstroNvim/astrocommunity" }, + -- { import = "astrocommunity.pack.lua" }, + { import = "plugins" }, -- import/override with your plugins + }), + defaults = { + -- By default, only AstroNvim plugins will be lazy-loaded. Your custom plugins will load during startup. + -- If you know what you're doing, you can set this to `true` to have all your custom plugins lazy-loaded by default. + lazy = true, + }, + install = { colorscheme = { "astrodark", "habamax" } }, + checker = { enabled = false }, -- automatically check for plugin updates + performance = { + rtp = { + -- disable some rtp plugins, add more to your liking + disabled_plugins = { + "gzip", + "netrwPlugin", + "tarPlugin", + "tohtml", + "zipPlugin", + }, + }, + }, +} diff --git a/lua/config/options.lua b/lua/config/options.lua new file mode 100644 index 0000000..3e3147b --- /dev/null +++ b/lua/config/options.lua @@ -0,0 +1,10 @@ +-- Options are automatically loaded before lazy.nvim startup +-- Default options that are always set: https://github.com/AstroNvim/AstroNvim/blob/main/lua/astronvim/options.lua +-- Add any additional options here +vim.opt.relativenumber = true -- sets vim.opt.relativenumber +vim.opt.number = true -- sets vim.opt.number +vim.opt.spell = false -- sets vim.opt.spell +vim.opt.signcolumn = "auto" -- sets vim.opt.signcolumn to auto +vim.opt.wrap = false -- sets vim.opt.wrap + +vim.g.mapleader = " " -- sets vim.g.mapleader diff --git a/lua/config/polish.lua b/lua/config/polish.lua new file mode 100644 index 0000000..123798f --- /dev/null +++ b/lua/config/polish.lua @@ -0,0 +1,16 @@ +-- This file is automatically ran last in the setup process and is a good place to configure +-- augroups/autocommands and custom filetypes also this just pure lua so +-- anything that doesn't fit in the normal config locations above can go here + +-- Set up custom filetypes +-- vim.filetype.add { +-- extension = { +-- foo = "fooscript", +-- }, +-- filename = { +-- ["Foofile"] = "fooscript", +-- }, +-- pattern = { +-- ["~/%.config/foo/.*"] = "fooscript", +-- }, +-- } diff --git a/lua/plugins/astrocore.lua b/lua/plugins/astrocore.lua new file mode 100644 index 0000000..4b35d35 --- /dev/null +++ b/lua/plugins/astrocore.lua @@ -0,0 +1,42 @@ +return { + "AstroNvim/astrocore", + opts = { + features = { + max_file = { size = 1024 * 100, 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 + highlighturl = true, -- highlight URLs at start + notifications = true, -- enable notifications at start + }, + -- Mapping data with "desc" stored directly by vim.keymap.set(). + -- + -- Please use this mappings table to set keyboard mapping since this is the + -- lower level configuration and more robust one. (which-key will + -- automatically pick-up stored data by this setting.) + mappings = { + -- first key is the mode + n = { + -- second key is the lefthand side of the map + -- mappings seen under group name "Buffer" + ["bn"] = { "tabnew", desc = "New tab" }, + ["bD"] = { + function() + require("astronvim.utils.status").heirline.buffer_picker( + function(bufnr) require("astronvim.utils.buffer").close(bufnr) end + ) + end, + desc = "Pick to close", + }, + -- 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 = { + -- setting a mapping to false will disable it + -- [""] = false, + }, + }, + }, +} diff --git a/lua/plugins/astrolsp.lua b/lua/plugins/astrolsp.lua new file mode 100644 index 0000000..2c48e32 --- /dev/null +++ b/lua/plugins/astrolsp.lua @@ -0,0 +1,39 @@ +return { + "AstroNvim/astrolsp", + opts = { + -- Diagnostics configuration (for vim.diagnostics.config({...})) when diagnostics are on + diagnostics = { + virtual_text = true, + underline = true, + }, + -- customize lsp formatting options + formatting = { + -- control auto formatting on save + format_on_save = { + enabled = true, -- enable or disable format on save globally + allow_filetypes = { -- enable format on save for specified filetypes only + -- "go", + }, + ignore_filetypes = { -- disable format on save for specified filetypes + -- "python", + }, + }, + disabled = { -- disable formatting capabilities for the listed language servers + -- disable lua_ls formatting capability if you want to use StyLua to format your lua code + -- "lua_ls", + }, + timeout_ms = 1000, -- default format timeout + -- filter = function(client) -- fully override the default formatting function + -- return true + -- end + }, + -- enable servers that you already have installed without mason + servers = { + -- "pyright" + }, + -- customize language server configuration options passed to `lspconfig` + config = { + -- clangd = { capabilities = { offsetEncoding = "utf-8" } }, + }, + }, +} diff --git a/lua/plugins/astroui.lua b/lua/plugins/astroui.lua new file mode 100644 index 0000000..f4cf597 --- /dev/null +++ b/lua/plugins/astroui.lua @@ -0,0 +1,14 @@ +return { + "AstroNvim/astroui", + opts = { + colorscheme = "astrodark", -- change colorscheme + highlights = { + init = { -- this table overrides highlights in all themes + -- Normal = { bg = "#000000" }, + }, + duskfox = { -- a table of overrides/changes to the duskfox theme + -- Normal = { bg = "#000000" }, + }, + }, + }, +} diff --git a/plugins/core.lua b/lua/plugins/core.lua similarity index 100% rename from plugins/core.lua rename to lua/plugins/core.lua diff --git a/plugins/mason.lua b/lua/plugins/mason.lua similarity index 85% rename from plugins/mason.lua rename to lua/plugins/mason.lua index 6566f34..a131e3f 100644 --- a/plugins/mason.lua +++ b/lua/plugins/mason.lua @@ -6,7 +6,7 @@ return { -- 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("astronvim.utils").list_insert_unique(opts.ensure_installed, { + opts.ensure_installed = require("astrocore.utils").list_insert_unique(opts.ensure_installed, { -- "lua_ls", }) end, @@ -17,7 +17,7 @@ return { -- 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("astronvim.utils").list_insert_unique(opts.ensure_installed, { + opts.ensure_installed = require("astrocore.utils").list_insert_unique(opts.ensure_installed, { -- "prettier", -- "stylua", }) @@ -28,7 +28,7 @@ return { -- 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("astronvim.utils").list_insert_unique(opts.ensure_installed, { + opts.ensure_installed = require("astrocore.utils").list_insert_unique(opts.ensure_installed, { -- "python", }) end, diff --git a/plugins/null-ls.lua b/lua/plugins/null-ls.lua similarity index 100% rename from plugins/null-ls.lua rename to lua/plugins/null-ls.lua diff --git a/plugins/treesitter.lua b/lua/plugins/treesitter.lua similarity index 78% rename from plugins/treesitter.lua rename to lua/plugins/treesitter.lua index 18c6da6..0fcf76d 100644 --- a/plugins/treesitter.lua +++ b/lua/plugins/treesitter.lua @@ -2,7 +2,7 @@ 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("astronvim.utils").list_insert_unique(opts.ensure_installed, { + opts.ensure_installed = require("astrocore.utils").list_insert_unique(opts.ensure_installed, { -- "lua" }) end, diff --git a/plugins/user.lua b/lua/plugins/user.lua similarity index 100% rename from plugins/user.lua rename to lua/plugins/user.lua diff --git a/mappings.lua b/mappings.lua deleted file mode 100644 index d87f7de..0000000 --- a/mappings.lua +++ /dev/null @@ -1,28 +0,0 @@ --- Mapping data with "desc" stored directly by vim.keymap.set(). --- --- Please use this mappings table to set keyboard mapping since this is the --- lower level configuration and more robust one. (which-key will --- automatically pick-up stored data by this setting.) -return { - -- first key is the mode - n = { - -- second key is the lefthand side of the map - -- mappings seen under group name "Buffer" - ["bn"] = { "tabnew", desc = "New tab" }, - ["bD"] = { - function() - require("astronvim.utils.status").heirline.buffer_picker(function(bufnr) require("astronvim.utils.buffer").close(bufnr) end) - end, - desc = "Pick to close", - }, - -- tables with the `name` key will be registered with which-key if it's installed - -- this is useful for naming menus - ["b"] = { name = "Buffers" }, - -- quick save - -- [""] = { ":w!", desc = "Save File" }, -- change description but the same command - }, - t = { - -- setting a mapping to false will disable it - -- [""] = false, - }, -} diff --git a/options.lua b/options.lua deleted file mode 100644 index 74ed9ad..0000000 --- a/options.lua +++ /dev/null @@ -1,30 +0,0 @@ --- set vim options here (vim.. = value) -return { - opt = { - -- set to true or false etc. - 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 - }, - g = { - mapleader = " ", -- sets vim.g.mapleader - autoformat_enabled = true, -- enable or disable auto formatting at start (lsp.formatting.format_on_save must be enabled) - cmp_enabled = true, -- enable completion at start - autopairs_enabled = true, -- enable autopairs at start - diagnostics_mode = 3, -- set the visibility of diagnostics in the UI (0=off, 1=only show in status line, 2=virtual text off, 3=all on) - icons_enabled = true, -- disable icons in the UI (disable if no nerd font is available, requires :PackerSync after changing) - ui_notifications_enabled = true, -- disable notifications when toggling UI elements - resession_enabled = false, -- enable experimental resession.nvim session management (will be default in AstroNvim v4) - }, -} --- If you need more control, you can use the function()...end notation --- return function(local_vim) --- local_vim.opt.relativenumber = true --- local_vim.g.mapleader = " " --- local_vim.opt.whichwrap = vim.opt.whichwrap - { 'b', 's' } -- removing option from list --- local_vim.opt.shortmess = vim.opt.shortmess + { I = true } -- add to option list --- --- return local_vim --- end diff --git a/plugins/community.lua b/plugins/community.lua deleted file mode 100644 index 6918be5..0000000 --- a/plugins/community.lua +++ /dev/null @@ -1,9 +0,0 @@ -return { - -- Add the community repository of plugin specifications - "AstroNvim/astrocommunity", - -- example of imporing a plugin, comment out to use it or add your own - -- available plugins can be found at https://github.com/AstroNvim/astrocommunity - - -- { import = "astrocommunity.colorscheme.catppuccin" }, - -- { import = "astrocommunity.completion.copilot-lua-cmp" }, -}