Skip to content

pedroresende/nvim-sync.nvim

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

nvim-sync.nvim

🔄 A Neovim plugin for syncing your configuration across multiple devices using GitHub.

✨ Features

  • 🚀 One-time setup: Ask for GitHub repository once and store configuration locally
  • 🔄 Auto-sync on startup: Automatically sync your configuration when Neovim starts
  • 📱 Multi-device support: Keep your configuration in sync across all your machines
  • ⚙️ Configurable: Customize sync behavior, commit messages, and more
  • 🔧 Easy management: Simple commands for manual sync operations
  • 🔒 Privacy-focused: Repository settings stored locally (not synced)

📦 Installation

Using Lazy.nvim (Recommended)

Add to your plugin configuration:

{
  "pedroresende/nvim-sync.nvim",
  lazy = false,
  priority = 1000,
  opts = {
    -- Optional configuration
    auto_sync = false,        -- Set to true for automatic sync on save
    sync_on_startup = true,   -- Sync on Neovim startup
    branch = "main",          -- Git branch to use
  },
}
use {
  'pedroresende/nvim-sync.nvim',
  config = function()
    require('nvim-sync').setup({
      -- your configuration here
    })
  end
}

Manual Installation

git clone https://github.com/pedroresende/nvim-sync.nvim.git ~/.local/share/nvim/site/pack/packer/start/nvim-sync.nvim

🚀 Quick Start

  1. Install the plugin using your preferred method above
  2. Restart Neovim
  3. First-time setup: You'll be prompted for:
    • GitHub username
    • Repository name (defaults to "nvim-config")
  4. Done! Your configuration will now sync automatically

📖 Usage

Commands

Command Description
:NvimSyncStatus Show Git status of your configuration
:NvimSyncPull Pull changes from remote repository
:NvimSyncPush Push local changes to remote repository
:NvimSync Full sync (pull then push)
:NvimSyncCommit Commit changes with a timestamped message
:NvimSyncConfigure Reconfigure GitHub repository settings
:NvimSyncInit Initialize a new Git repository
:NvimSyncCleanup Clean up git lock files and resolve issues

Key Mappings

Key Action
<leader>gs Git Status
<leader>gpl Git Pull
<leader>gps Git Push
<leader>gy Git Sync (Pull + Push)

Workflow Example

Setting up on a new machine:

# 1. Clone your nvim config
git clone https://github.com/yourusername/nvim-config ~/.config/nvim

# 2. Start Neovim (plugin will be installed via your package manager)
nvim

# 3. Plugin automatically syncs your latest configuration

Daily workflow:

  1. Make changes to your configuration
  2. Restart Neovim → automatic sync
  3. Or manually run :NvimSync

⚙️ Configuration

require('nvim-sync').setup({
  auto_sync = false,                              -- Auto-sync on file save
  sync_on_startup = true,                         -- Sync when Neovim starts
  commit_message_template = "Auto-sync - %s",     -- Commit message template
  branch = "main",                                -- Git branch to use
  config_file_name = "sync-config.lua",           -- Local config file name
})

🔧 Advanced Usage

Changing Repository

To switch to a different repository:

:NvimSyncConfigure

This will prompt for new GitHub username and repository name.

Manual Git Operations

The plugin provides direct access to git operations:

:NvimSyncStatus    " Check what files have changed
:NvimSyncPull      " Pull latest changes
:NvimSyncPush      " Push your changes
:NvimSyncCommit    " Commit changes with a timestamped message
:NvimSyncCleanup   " Clean up git lock files if you encounter issues

🛠️ Troubleshooting

Git Lock File Issues

If you encounter errors like "could not lock config file .git/config: File exists", the plugin automatically cleans up lock files before each operation. However, you can also manually run:

:NvimSyncCleanup

Authentication Issues

  • HTTPS Authentication: If you're using HTTPS URLs and getting authentication prompts, consider switching to SSH
  • SSH Setup: Make sure you have SSH keys set up with GitHub for seamless authentication
  • Repository Access: Ensure you have push access to the configured repository

Plugin Not Working

  1. Check if the plugin loaded: Look for "Nvim Sync plugin loaded successfully!" message
  2. Verify git is installed: The plugin requires git to be available in your PATH
  3. Check configuration: Run :NvimSyncStatus to see current repository status

🤝 Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

📄 License

MIT License - see LICENSE file for details.

About

Nvim configuration sync

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages