/AstroVim

AstroVim is an aesthetic and feature-rich neovim config that is extensible and easy to use with a great set of plugins

Primary LanguageLuaGNU General Public License v3.0GPL-3.0

AstroVim

AstroVim is an aesthetic and feature-rich neovim config that is extensible and easy to use with a great set of plugins

BREAKING RELEASE NOTICE: If you were using AstroVim before the official release, please see the updated user configuration in the lua/user_example folder as well as the updated configuration details below and in the user_example README. The official release came with a lot of restructuring changes to make things easier and more "future-proof".

🌟 Preview

Preview1 Preview2 Preview33

⚡ Requirements

🛠️ Installation

Linux

Make a backup of your current nvim folder

mv ~/.config/nvim ~/.config/nvimbackup

Clone the repository

git clone https://github.com/kabinspace/AstroVim ~/.config/nvim
nvim +PackerSync

📦 Setup

Install LSP

Enter :LspInstall followed by the name of the server you want to install
Example: :LspInstall pyright

Install language parser

Enter :TSInstall followed by the name of the language you want to install
Example: :TSInstall python

Manage plugins

Run :PackerClean to remove any disabled or unused plugins
Run :PackerSync to update and clean plugins

Update AstroVim

Run :AstroUpdate to get the latest updates from the repository

✨ Features

⚙️ Configuration

To begin making custom user configurations you must create a user/ folder. The provided example can be created with (please note the trailing slashes after the directory names)

cp -r ~/.config/nvim/lua/user_example/ ~/.config/nvim/lua/user/

The provided example user_example contains an init.lua file which can be used for all user configuration. After running the cp command above this file can be found in ~/.config/nvim/lua/user/init.lua.

Advanced Configuration Options are described in the AstroVim wiki

Extending AstroVim

AstroVim should allow you to extend its functionality without going outside of the user directory!

Please get in contact when you run into some setup issue where that is not the case.

Add more Plugins

Just copy the packer configuration without the use and with a , after the last closing } into the plugins.init entry of your user/init.lua file.

See the example in the user_example directory.

Change Default Plugin Configurations

AstroVim allows you to easily override the setup of any pre-configured plugins. Simply add a table to the plugins table with a key the same name as the plugin package and return a table with the new options or overrides that you want. For an example see the included plugins entry for treesitter in the user_example folder which lets you extend the default treesitter configuration.

Change Default Packer Configuration

The plugins table extensibility includes the packer configuration for all plugins, user plugins as well as plugins configured by AstroVim.

E.g. this code in your init.lua plugins.init table entry to remove dashboard-nvim and disable lazy loading of toggleterm:

plugins = {
  -- if the plugins init table can be a function on the default plugin table
  -- instead of a table to be extended. This lets you modify the details of the default plugins
  init = function(plugins)
    -- add your new plugins to this table
    local my_plugins = {
      -- { "andweeb/presence.nvim" },
      -- {
      --   "ray-x/lsp_signature.nvim",
      --   event = "BufRead",
      --   config = function()
      --     require("lsp_signature").setup()
      --   end,
      -- },
    }

    -- Remove a default plugins all-together
    plugins["glepnir/dashboard-nvim"] = nil

    -- Modify default plugin packer configuration
    plugins["akinsho/nvim-toggleterm.lua"]["cmd"] = nil

    -- add the my_plugins table to the plugin table
    return vim.tbl_deep_extend("force", plugins, my_plugins)
  end,
},

Adding sources to nvim-cmp

To add new completion sources to nvim-cmp you can add the plugin (see above) providing that source like this:

plugins = {
  init = {
    {
      "Saecki/crates.nvim",
      after = "nvim-cmp",
      config = function()
        require("crates").setup()

        local cmp = require "cmp"
        local config = cmp.get_config()
        table.insert(config.sources, { name = "crates" })
        cmp.setup(config)
      end,
    },
  },
},

Use the options provided by nvim-cmp to change the order, etc. as you see fit.

Add Custom LSP Server Settings

You might want to override the default LSP settings for some servers to enable advanced features. This can be achieved with the lsp.server-settings table inside of your user/init.lua config and creating entries where the keys are equal to the LSP server. Examples of these table entries can be found in /lua/configs/lsp/server-settings.

For example, if you want to add schemas to the yamlls LSP server, you can add the following to the user/init.lua file:

lsp = {
  ["server-settings"] = {
    yamlls = {
      settings = {
        yaml = {
          schemas = {
            ["http://json.schemastore.org/github-workflow"] = ".github/workflows/*.{yml,yaml}",
            ["http://json.schemastore.org/github-action"] = ".github/action.{yml,yaml}",
            ["http://json.schemastore.org/ansible-stable-2.9"] = "roles/tasks/*.{yml,yaml}",
          },
        },
      },
    },
  },
},

Compley LSP server setup

Some plugins need to do special magic to the LSP configuration to enable advanced features. One example for this is the rust-tools.nvim plugin.

Those can override lsp.server_registration.

For example the rust-tools.nvim plugin can be set up in the user/init.lua file as follows:

plugins = {
  init = {
    -- Plugin definition:
    {
      "simrat39/rust-tools.nvim",
      requires = { "nvim-lspconfig", "nvim-lsp-installer", "nvim-dap", "Comment.nvim" },
      -- Is configured via the server_registration_override installed below!
    },
  },
},

lsp = {
  server_registration = function(server, server_opts)
    -- Special code for rust.tools.nvim!
    if server.name == "rust_analyzer" then
      local extension_path = vim.fn.stdpath "data" .. "/dapinstall/codelldb/extension/"
      local codelldb_path = extension_path .. "adapter/codelldb"
      local liblldb_path = extension_path .. "lldb/lib/liblldb.so"

      require("rust-tools").setup {
        server = server_opts,
        dap = {
          adapter = require("rust-tools.dap").get_codelldb_adapter(codelldb_path, liblldb_path),
        },
      }
    else
      server:setup(server_opts)
    end
  end,
},

Extending the LSP on_attach Function

Some users may want to have more control over the on_attach function of their LSP servers to enable or disable capabilities. This can be extended with lsp.on_attach in the user/init.lua file.

For example if you want to disable document formatting for intelephense in user/init.lua:

lsp = {
  on_attach = function(client, bufnr)
    if client.name == "intelephense" then
      client.resolved_capabilities.document_formatting = false
      client.resolved_capabilities.document_range_formatting = false
    end
  end,
},

More Configuration Options

More detailed explanations of the possible configuration options are described in the AstroVim wiki

🗒️ Note

Guide is given for basic usage
Learn more about the default key bindings
Watch a review video to know about the out of the box experience

⭐ Credits

Sincere appreciation to the following repositories, plugin authors and the entire neovim community out there that made the development of AstroVim possible.

Lua