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