Home

Awesome

distroupdate.nvim

Distro agnostic Neovim plugin to upgrade your current distro from its github remote.

screenshot_2024-03-10_23-20-38_444541684

<div align="center"> <a href="https://discord.gg/ymcMaSnq7d" rel="nofollow"> <img src="https://img.shields.io/discord/1121138836525813760?color=azure&labelColor=6DC2A4&logo=discord&logoColor=black&label=Join the discord server&style=for-the-badge" data-canonical-src="https://img.shields.io/discord/1121138836525813760"> </a> </div>

Table of contents

Why

If you use Neovim in multiple machines, you can use the command :DistroUpdate to get the latest changes of your config from your GitHub repository from any device.

If you are developing a Neovim distro, you can ship this plugin, and users will get updates from your distro GitHub repository when they run :DistroUpdate.

Warning

Currently, running :DistroUpdate will overwrite any uncommited change in your local nvim config.

How to install

This plugin requires you to use lazy package manager

{
  "Zeioth/distroupgrade.nvim",
  dependencies = "nvim-lua/plenary.nvim",
  event = "VeryLazy",
  opts = {}
}

Available commands

CommandDescription
:DistroUpdateIf the value of the option channel is stable, it will update from the latest available released version of the remote of the git repository of your nvim config. If the value of channel is nightly, it will update from the latest changes in the branch nightly of the git repository of you nvim config.
:DistroUpdateRevertUses git to bring your config to the state it had before running :DistroUpdate.
:DistroFreezePluginVersionsSaves your current plugin versions into lazy_versions.lua in your config directory. You can import this file and pass it to your lazy config, so it respect your locked versions. Check the option spec in lazy.
:DistroReadVersionPrints the commit number of the current distro version.
:DistroReadChangelogPrints the changelog.

Available options

All options described here are 100% optional and you don't need to define them to use this plugin.

NameDefault valueDescription
channelstableChannel used by the command :DistroUpdate. stable will update the distro from the latest available released version of your git repository. nightly will update the distro from the main branch of your git repository.
hot_reload_files{}The files included, will be hot reloaded every time you write them. This way you can see the changes in your config reflected without having to restart nvim. For example: { my_nvim_opts_file, my_nvim_mappings_file}. Be aware this feature is experimental, and might not work in all cases yet.
hot_reload_callbackfunction() end(optional) Extra things to do after the files defined in the option hot_reload_files are reloaded. For example: This can be handy if you want to re-apply your theme.
release_tagnilIf this option is specified, the option channel will be ignored, and the updater will download the release you specify. The format must be semantic versioning, like: "v1.0".
remoteoriginGit remote of your distro repository.
snapshot_file<nvim_config_dir>/lua/lazy_snapshot.luaFile used by the command :DistroFreezePluginVersions to write the plugins.
rollback_file<nvim_cache_dir>/rollback.luaRollback file automatically triggered by :DistroUpdate. This file will be used when you use :DistroUpdateRevert

Example of a real config

-- distroupdate.nvim [distro update]
-- https://github.com/Zeioth/distroupdate.nvim
{
  "Zeioth/distroupdate.nvim",
  dependencies = { "nvim-lua/plenary.nvim" },
  event = "VeryLazy",
  opts = function()
    local config_dir = vim.fn.stdpath "config" .. "/lua/base/"
    return {
      remote = "origin",
      channel = "stable",                                             -- stable/nightly.
      release_tag = nil,                                              -- in case you wanna freeze a specific distro version.
      hot_reload_files = {
        config_dir .. "1-options.lua",
        config_dir .. "4-mappings.lua"
      },
      hot_reload_callback = function()
        vim.cmd ":silent! doautocmd ColorScheme"                     -- heirline colorscheme reload event.
        vim.cmd(":silent! colorscheme " .. base.default_colorscheme) -- nvim     colorscheme reload command.
      end
    }
  end
},

Credits

Many of the GPL3 lua libraries this plugin use come from AstroNvim and NormalNvim. So please support both projects if you enjoy this plugin.

FAQ