diff --git a/.luarc.json b/.luarc.json new file mode 100644 index 00000000..8415579f --- /dev/null +++ b/.luarc.json @@ -0,0 +1,3 @@ +{ + "format.enable": false +} diff --git a/README.md b/README.md index 365674b3..4488bde8 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # AstroNvim Template -**NOTE:** This is for AstroNvim v4+ +**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 2ce1cdd2..424e48dd 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/lazy_setup.lua b/lua/lazy_setup.lua index 939d7b7b..8e1abfbd 100644 --- a/lua/lazy_setup.lua +++ b/lua/lazy_setup.lua @@ -1,7 +1,7 @@ require("lazy").setup({ { "AstroNvim/AstroNvim", - version = "^4", -- Remove version tracking to elect for nighly 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 diff --git a/lua/plugins/astrocore.lua b/lua/plugins/astrocore.lua index cda56a89..03d7441f 100644 --- a/lua/plugins/astrocore.lua +++ b/lua/plugins/astrocore.lua @@ -15,7 +15,7 @@ return { 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_mode = 3, -- diagnostic mode on start (0 = off, 1 = no signs/virtual text, 2 = no virtual text, 3 = on) + diagnostics = { virtual_text = true, virtual_lines = false }, -- diagnostic settings on startup highlighturl = true, -- highlight URLs at start notifications = true, -- enable notifications at start }, @@ -24,6 +24,19 @@ return { virtual_text = true, underline = true, }, + -- passed to `vim.filetype.add` + filetypes = { + -- see `:h vim.filetype.add` for usage + extension = { + foo = "fooscript", + }, + filename = { + [".foorc"] = "fooscript", + }, + pattern = { + [".*/etc/foo/.*"] = "fooscript", + }, + }, -- vim options can be configured here options = { opt = { -- vim.opt. diff --git a/lua/plugins/astrolsp.lua b/lua/plugins/astrolsp.lua index 720b9d36..b8b121f2 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/mason.lua b/lua/plugins/mason.lua index 34296614..2d79b5f1 100644 --- a/lua/plugins/mason.lua +++ b/lua/plugins/mason.lua @@ -1,38 +1,27 @@ if true then return {} end -- WARN: REMOVE THIS LINE TO ACTIVATE THIS FILE --- Customize Mason plugins +-- 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 = { - ensure_installed = { - "lua_ls", - -- add more arguments for adding more language servers - }, - }, - }, - -- 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(...)` + "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 - }, - }, - }, - { - "jay-babu/mason-nvim-dap.nvim", - -- overrides `require("mason-nvim-dap").setup(...)` - opts = { - ensure_installed = { - "python", - -- add more arguments for adding more debuggers + + -- install debuggers + "debugpy", + + -- install any other package + "tree-sitter-cli", }, }, }, diff --git a/lua/plugins/treesitter.lua b/lua/plugins/treesitter.lua index 94436aad..3a9afe99 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 121089ef..d3326273 100644 --- a/lua/plugins/user.lua +++ b/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: @@ -46,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 14c38cd4..642719fe 100644 --- a/lua/polish.lua +++ b/lua/polish.lua @@ -1,18 +1,5 @@ if true then return end -- WARN: REMOVE THIS LINE TO ACTIVATE THIS FILE --- This will run last in the setup process and is a good place to configure --- things like custom filetypes. This just pure lua so anything that doesn't +-- 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 - --- Set up custom filetypes -vim.filetype.add { - extension = { - foo = "fooscript", - }, - filename = { - ["Foofile"] = "fooscript", - }, - pattern = { - ["~/%.config/foo/.*"] = "fooscript", - }, -}