Configure synchronization of files and directories through a plugin.
| 1 | # syncmap.nvim |
| 2 | |
| 3 | A lightweight Neovim plugin that keeps directories in sync using `inotifywait`, `rsync`, and some clever Vimscript + Lua integration. |
| 4 | |
| 5 | ## Motivation |
| 6 | |
| 7 | - Dotfiles |
| 8 | |
| 9 | ## Features |
| 10 | |
| 11 | - Automatically sync source → destination directories on file changes |
| 12 | - Uses `inotifywait`, `pgrep`, `pkill`, and `rsync` |
| 13 | - Supports `.gitignore`-like exclusions via `--exclude-from` |
| 14 | - Reverse sync on startup (optional) |
| 15 | - Logs and restarts lost watchers automatically |
| 16 | - Fully typed config for autocompletion and inline docs |
| 17 | - Automatically expands paths in the config |
| 18 | |
| 19 | ## Warning |
| 20 | |
| 21 | - Updates made in the dst will be overwritten by the updates made in src |
| 22 | |
| 23 | ## Requirements |
| 24 | |
| 25 | - Linux (uses `inotifywait`) |
| 26 | - Neovim 0.8+ |
| 27 | - Tools: |
| 28 | - `inotifywait` (from `inotify-tools`) |
| 29 | - `rsync` |
| 30 | - `pgrep` and `pkill` (from `procps-ng`) |
| 31 | |
| 32 | ## Installation |
| 33 | |
| 34 | Using [lazy.nvim](https://github.com/folke/lazy.nvim): |
| 35 | |
| 36 | ```lua |
| 37 | { |
| 38 | dir = vim.fn.expand("~/code/nvim-plugins/syncmap/"), |
| 39 | name = "syncmap.nvim", |
| 40 | opts = { |
| 41 | map = { |
| 42 | { "~/.dotfiles/test/", "~/.config/test/" }, |
| 43 | }, |
| 44 | log_level = "info", |
| 45 | }, |
| 46 | } |
| 47 | ```` |
| 48 | |
| 49 | ## Default Options |
| 50 | |
| 51 | ```lua |
| 52 | { |
| 53 | map = { |
| 54 | { "~/.dotfiles/nvim/", "~/.config/nvim/" }, |
| 55 | }, |
| 56 | reverse_sync_on_startup = true, |
| 57 | rsync = { "-a", "--delete" }, |
| 58 | log_level = "error", |
| 59 | } |
| 60 | ``` |
| 61 | |
| 62 | ## Type Hints |
| 63 | |
| 64 | For inline type hints and autocomplete, annotate your `opts` using: |
| 65 | |
| 66 | ```lua |
| 67 | if false then |
| 68 | require("syncmap.types") |
| 69 | require("lazy.types") |
| 70 | end |
| 71 | ---@type LazySpec |
| 72 | return { |
| 73 | "huncholane/syncmap.nvim", |
| 74 | ---@type SyncmapOpts |
| 75 | opts = { |
| 76 | map = { |
| 77 | { "~/.dotfiles/nvim/", "~/.config/nvim/" }, |
| 78 | { "~/.dotfiles/tmux/", "~/.config/tmux/" }, |
| 79 | }, |
| 80 | }, |
| 81 | } |
| 82 | ``` |
| 83 | |
| 84 | or ... |
| 85 | |
| 86 | ```lua |
| 87 | if false then |
| 88 | require("syncmap.types") |
| 89 | require("lazy.types") |
| 90 | end |
| 91 | return { |
| 92 | ---@type LazySpec |
| 93 | { |
| 94 | "huncholane/syncmap.nvim", |
| 95 | ---@type SyncmapOpts |
| 96 | opts = { |
| 97 | map = { |
| 98 | { "~/.dotfiles/nvim/", "~/.config/nvim/" }, |
| 99 | { "~/.dotfiles/tmux/", "~/.config/tmux/" }, |
| 100 | }, |
| 101 | }, |
| 102 | } |
| 103 | } |
| 104 | ``` |
| 105 | |
| 106 | ## Type Sample |
| 107 | |
| 108 |  |
| 109 | |
| 110 | This gives you full visibility into available options and correct types. |
| 111 | |
| 112 | --- |
| 113 | |
| 114 | ### LICENSE |
| 115 | |
| 116 | ```txt |
| 117 | MIT License |
| 118 | |
| 119 | Copyright (c) 2025 huncholane |
| 120 | |
| 121 | Permission is hereby granted, free of charge, to any person obtaining a copy |
| 122 | of this software and associated documentation files (the "Software"), to deal |
| 123 | in the Software without restriction, including without limitation the rights |
| 124 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell |
| 125 | copies of the Software, and to permit persons to whom the Software is |
| 126 | furnished to do so, subject to the following conditions: |
| 127 | |
| 128 | The above copyright notice and this permission notice shall be included in all |
| 129 | copies or substantial portions of the Software. |
| 130 | |
| 131 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
| 132 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
| 133 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE |
| 134 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
| 135 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
| 136 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE |
| 137 | SOFTWARE. |
| 138 | ``` |
| 139 | |
| 140 | --- |