1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
|
rclone.nvim
===
Uses [rclone](https://rclone.org/) under the hood.
`copy` or `sync` folders
or copy the file in the current buffer
to a remote in your `rclone.conf`
download folders
or download the file in the current buffer
from a remote
or `mount` a remote
## Table of Contents
- [Commands](#commands)
- [Usage](#usage)
- [Install](#install)
## Commands
```
:Rclone [<command>] [<remote>] [options]
Arguments:
command Command to run: [copy, copyFile, download, downloadFile, sync, mount, unmount]
remote Name of the remote section defined in rclone.conf
If only one remote is specified that remote is used by default.
Otherwise the remote with "vim_rclone_default = true" is used.
Options:
--dry-run Print command to run and don't execute
```
## Usage
Example `rclone.conf`
```
[Test]
type = sftp
host = example.org
user = admin
pass = pa55w0rd
vim_rclone_local_path = .
vim_rclone_remote_path = /test
vim_rclone_mount_directory = testmount
[Test_another]
type = sftp
host = example.org
user = admin
pass = pa55w0rd
vim_rclone_local_path = ./test_another
vim_rclone_remote_path = /test/another
vim_rclone_default = true
```
### copy
`:Rclone copy` copies the local `test_another` folder to the remote `/test/another` because `vim_rclone_default` is set for the **Test_another** remote.
To upload to the **Test** remote use `:Rclone copy Test`.
The resulting command for `:Rclone copy` from the example above would be
```sh
rclone copy $PATH_TO_PROJECT/test_another Test_another:/test/another --config=./rclone.conf
--exclude=.git/ --exclude=.gitignore --exclude=.rcloneignore
--exclude-from=$PATH_TO_PROJECT/test_another/.gitignore --exclude-from=$PATH_TO_PROJECT/test_another/.rcloneignore
--log-level=INFO --log-file=${vim.fn.stdpath('data')}/rclone_nvim/rclone.log
```
#### exclude files
You can extend or overwrite the global `g:vim_rclone_configurable_default_exclude_patterns` variable.
The default patterns are
`{'.git/', '.gitignore', '.rcloneignore'}`
`rclone.nvim` uses the patterns defined in a `.gitignore` and `.rcloneignore`.
If you want to upload folders that are in the `.gitignore` like a `/build/` folder, then add `!/build/` to your `.rcloneignore`.
**Caution:**
[rclone exclude patterns](https://rclone.org/filtering/#pattern-syntax) for folders **need** a trailing slash.
If you have ignored folders in your `.gitignore` then you have to add a trailing slash to them, or define them separately in the `.rcloneignore`.
### download
Downloading with `:Rclone download` works the same, the local and remote paths are just swapped like this
```sh
rclone copy Test_another:/test/another $PATH_TO_PROJECT/test_another [...]
```
### mount
Suppose following `rclone.conf`
```
[Test]
type = sftp
host = example.org
user = admin
pass = pa55w0rd
vim_rclone_local_path = ./test_local
vim_rclone_remote_path = /test_remote
vim_rclone_mount_directory = testmount
```
The resulting command for `:Rclone mount` would be
```sh
rclone mount Test:/test_remote $PATH_TO_PROJECT/test_local/testmount --config=./rclone.conf
--log-format=pid --log-file=${vim.fn.stdpath('data')}/rclone_nvim/rclone-mount.log
--read-only --no-checksum --daemon
```
The default mount directory name is `rclone.mount`.
You can adjust that either by setting the `directory` parameter when running the command with `:Rclone mount directory=othertestmount`,
within your `rclone.conf`,
or by setting `g:vim_rclone_mount_directory`.
#### unmount
When running `:Rclone unmount` the pid for the spawned process is identified by
looking for the complete command used when mounting and is just `kill`ed.
So you need to specify the directory parameter as well if it was used when mounting.
## Install
Like any other nvim plugin.
For example with [vim-plug](https://github.com/junegunn/vim-plug)
```vim
Plug 'https://gitlab.com/dweipert.de/rclone.nvim'
```
|