Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/niuiic/remote.nvim
Edit remote files locally.
https://github.com/niuiic/remote.nvim
Last synced: about 2 months ago
JSON representation
Edit remote files locally.
- Host: GitHub
- URL: https://github.com/niuiic/remote.nvim
- Owner: niuiic
- License: mit
- Created: 2023-10-10T12:49:57.000Z (11 months ago)
- Default Branch: main
- Last Pushed: 2024-05-11T04:35:44.000Z (4 months ago)
- Last Synced: 2024-05-11T05:27:47.787Z (4 months ago)
- Language: Lua
- Homepage:
- Size: 23.4 KB
- Stars: 32
- Watchers: 2
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
- awesome-neovim - niuiic/remote.nvim - Edit remote files with local configuration. (Remote Development / Indent)
README
# remote.nvim
Edit remote files with local neovim configuration.
**Edit them as local directories.**
**No other dependencies required for remote machine except ssh.**
[More neovim plugins](https://github.com/niuiic/awesome-neovim-plugins)
## Usage
First add a configuration.
Here is an example.
```json
[
{
"host": "localhost",
"user": "user",
"passwd": "passwd",
"remote_dir": "/home/niuiic/Documents/projects/nvim/remote.nvim",
"mount_point": "remote.nvim",
"options": ["-p", 22]
},
{
"host": "10.10.11.12",
"user": "user",
"passwd": "passwd",
"remote_dir": "/home/niuiic/Documents/projects/nvim/remote2.nvim",
"mount_point": "remote2.nvim"
}
]
```> `remote_dir` and `mount_point` should be directories. `options` will be passed to `sshfs`.
Then you can connect to remote directory with `require("remote").connect()`.
Avaliable functions.
| function | desc |
| ----------- | --------------------------------- |
| connect | connect to the remote directories |
| disconnect | disconnect |
| reconnect | reconnect |
| edit_config | edit configuration |
| check_log | check log file |## Dependencies
- [sshfs](https://github.com/libfuse/sshfs)
- [sshpass](https://sourceforge.net/projects/sshpass)
- umount
- [niuiic/core.nvim](https://github.com/niuiic/core.nvim)> All dependencies are only required locally.
## Config
Here is the default configuration.
```lua
{
config_file = ".nvim/remote.json",
log_file = ".nvim/remote.log",
unmount = function(path)
return "umount " .. path
end,
disconnect_on_leave = true,
---@type fun(config: remote.Config)
on_each_to_connect = function() end,
---@type fun(config: remote.Config)
on_each_connected = function() end,
---@type fun(config: remote.Config)
on_each_to_disconnect = function() end,
---@type fun(config: remote.Config)
on_each_disconnected = function() end,
}---@class remote.Config
---@field host string
---@field user string
---@field passwd string
---@field remote_dir string
---@field mount_point string
---@field options string[] | nil
```## Troubleshooting
- Remote directories were not mounted/unmounted correctly
Check log file, sshfs command may failed for some reason.
- Remote directories were not updated
Check the document of sshfs.
- Neovim is stuck
Someting wrong with ssh, cancel the task with `` and check you configuration.
- Failed to unmount directories
It may not be possiable to unmount the directories if ssh is unable to connect to the remote machine. You can modify the `unmount` option in configuration to force umount and avoid stuck process. (This always require root privileges, so it's an option.)