rsync-build.nvim is a Neovim plugin that provides a convenient way to upload local project to a remote server then build it in the remote.
It uses rsync to synchronize files and support flexible build commands.
NOTE: This plugin is a personal project, only basic features are implemented.
TODO:
- add support for tmux (for sharing terminal among neovim instances and preventing close the terminal when neovim exits)
- add options that support
deletesync, ignore dotfiles
This plugin is inspired from my daily workflow. I always open 3 tmux windows, they are:
- the Neovim window, for editing the source code and uploading it to the remote server with
vim-arsyncplugin; - the build window, since the source code needs to be built in the login node with the cross compiler;
- the run window, for running the executable in the compute node with interactive job.
This plugin is designed to simplify this workflow by providing a single command to upload the source code, build it, and run it.
{ "nahso/rsync-build.nvim" }
Then initialize the plugin with:
require("rsync-build").setup()
local rb = require("rsync-build")
vim.keymap.set("n", "<leader>l", function()
rb.upload_dir()
end, { desc = "Send file rsync-build" })Execute :TransferInit to create a template configuration file in the current directory. The template file is named .rsync-build.lua.
Here is an example of a .rsync-build.lua file:
return {
-- the none absolute paths are relative to the project root
host = "host1",
localPath = ".",
remotePath = "<path>",
excludedPaths = {
"build",
},
terminals = {
build = {
initial_commands = {
"ssh host1",
"cd <path>/build",
},
commands = {
"make -j",
},
},
run = {
initial_commands = {
"ssh host1",
"cd <path>/build",
"srun gpu --pty /bin/bash",
},
commands = {
"./<executable>",
},
}
},
actions = {
o = {
"build",
},
i = {
"build",
"run",
},
j = {
"run"
}
},
}Required fields are:
host: the remote server name, only the host configured in~/.ssh/configwith public key authentication is supportedlocalPath: the local path to uploadremotePath: the remote path to upload the files
Optional fields are:
excludedPaths: a list of paths to exclude from the uploadterminals: a list of terminals to open after the uploadinitial_commands: the initial commands, only executed oncecommands: the main command to run in the terminal
actions: a list of actions to perform after the upload, the key is the keybinding and the value is a list of terminal name defined interminals
Once the upload_dir() is bind to <leader>l, the build action can be triggered by <leader>lo, the run action can be triggered by <leader>lj, and the build then run action can be triggered by <leader>li.
If there is no actions defined, the <leader>l will only upload the local files to the remote server.