Configure synchronization of files and directories through a plugin.
added exclude from
1 file changed, +7 -3
+7-3lua/syncmap/utils.lua
| @@ -53,6 +53,7 @@ end | ||
| 53 | 53 | function M.extract_exclude_from(m) |
| 54 | 54 | if m.exclude_from == nil then |
| 55 | 55 | if M.opts.exclude_from ~= nil then |
| 56 | + m.exclude_from = M.opts.exclude_from | |
| 56 | 57 | return M.string_to_exclude_from(M.opts.exclude_from) |
| 57 | 58 | end |
| 58 | 59 | return nil |
| @@ -69,12 +70,15 @@ function M.extract_flags(m) | ||
| 69 | 70 | if flags == nil then |
| 70 | 71 | flags = M.opts.rsync |
| 71 | 72 | end |
| 73 | + local exclude_from = M.extract_exclude_from(m) | |
| 72 | 74 | if m.exclude_from == nil then |
| 73 | 75 | return flags |
| 74 | 76 | end |
| 75 | - if is_dir(m[1]) then | |
| 76 | - if file_exists(with_trailing_slash(m[1]) .. m.exclude_from) then | |
| 77 | - table.insert(flags, M.extract_exclude_from(m)) | |
| 77 | + local src = vim.fn.expand(m[1]) | |
| 78 | + local stat = vim.uv.fs_stat(src) | |
| 79 | + if stat and stat.type == "directory" then | |
| 80 | + if file_exists(with_trailing_slash(src) .. m.exclude_from) then | |
| 81 | + table.insert(flags, exclude_from) | |
| 78 | 82 | end |
| 79 | 83 | end |
| 80 | 84 | return flags |