irongit

Configure synchronization of files and directories through a plugin.

syncmap.nvim/README.md
140 lines3.1 KBMarkdown
1# syncmap.nvim
2
3A 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
34Using [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
64For inline type hints and autocomplete, annotate your `opts` using:
65
66```lua
67if false then
68 require("syncmap.types")
69 require("lazy.types")
70end
71---@type LazySpec
72return {
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
84or ...
85
86```lua
87if false then
88 require("syncmap.types")
89 require("lazy.types")
90end
91return {
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![type-sample]./doc/type.png
109
110This gives you full visibility into available options and correct types.
111
112---
113
114### LICENSE
115
116```txt
117MIT License
118
119Copyright (c) 2025 huncholane
120
121Permission is hereby granted, free of charge, to any person obtaining a copy
122of this software and associated documentation files (the "Software"), to deal
123in the Software without restriction, including without limitation the rights
124to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
125copies of the Software, and to permit persons to whom the Software is
126furnished to do so, subject to the following conditions:
127
128The above copyright notice and this permission notice shall be included in all
129copies or substantial portions of the Software.
130
131THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
132IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
133FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
134AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
135LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
136OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
137SOFTWARE.
138```
139
140---