Skip to content

Commit

Permalink
fix(provider): Correctly handle upload dirs for non-standard configur…
Browse files Browse the repository at this point in the history
…ations (#142)
  • Loading branch information
amitds1997 committed Jun 8, 2024
1 parent 2d5158a commit 6927788
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 23 deletions.
10 changes: 0 additions & 10 deletions .luarc.json

This file was deleted.

22 changes: 12 additions & 10 deletions lua/remote-nvim/providers/provider.lua
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ local utils = require("remote-nvim.utils")
local function get_copy_paths(copy_config)
local local_dirs = copy_config.dirs
if local_dirs == "*" then
return { copy_config.base }
return { utils.path_join(utils.is_windows, copy_config.base, ".") }
else
assert(
type(local_dirs) == "table",
Expand Down Expand Up @@ -650,21 +650,23 @@ function Provider:_setup_remote()
if self:_get_neovim_config_upload_preference() then
self:upload(
self._local_path_to_remote_neovim_config,
self._remote_xdg_config_path,
self._remote_neovim_config_path,
"Copying your Neovim configuration files onto remote"
)
end

-- If user has specified certain directories to copy over in the "state", "cache" or "data" directories, do it now
for key, value in pairs(self._local_path_copy_dirs) do
if not vim.tbl_isempty(value) then
for key, local_paths in pairs(self._local_path_copy_dirs) do
if not vim.tbl_isempty(local_paths) then
local remote_upload_path = utils.path_join(
self._remote_is_windows,
self["_remote_xdg_" .. key .. "_path"],
remote_nvim.config.remote.app_name
)

self:upload(
value,
utils.path_join(
self._remote_is_windows,
self["_remote_xdg_" .. key .. "_path"],
remote_nvim.config.remote.app_name
),
local_paths,
remote_upload_path,
("Copying over Neovim '%s' directories onto remote"):format(key),
remote_nvim.config.remote.copy_dirs[key].compression
)
Expand Down
6 changes: 3 additions & 3 deletions tests/remote-nvim/providers/provider_spec.lua
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,7 @@ describe("Provider", function()

assert.are.same({ "a/b/c", "a/b/d" }, provider._local_path_to_remote_neovim_config)
assert.are.same({
data = { "d/e" },
data = { "d/e/." },
cache = {},
state = { "h/e/x", "h/e/y", "h/e/z" },
}, provider._local_path_copy_dirs)
Expand Down Expand Up @@ -642,7 +642,7 @@ describe("Provider", function()
assert.stub(upload_stub).was.called_with(
match.is_ref(provider),
provider._local_path_to_remote_neovim_config,
"~/.remote-nvim/workspaces/akfdjakjfdk/.config",
"~/.remote-nvim/workspaces/akfdjakjfdk/.config/nvim",
match.is_string()
)
end)
Expand Down Expand Up @@ -766,7 +766,7 @@ describe("Provider", function()
)
assert.stub(upload_stub).was.called_with(
match.is_ref(provider),
{ "data-path" },
{ "data-path/." },
"~/.remote-nvim/workspaces/akfdjakjfdk/.local/share/nvim",
match.is_string(),
remote_nvim.config.remote.copy_dirs.data.compression
Expand Down

0 comments on commit 6927788

Please sign in to comment.