From 3285bbffe926ba5f54d1684f323d54fd4311a08e Mon Sep 17 00:00:00 2001 From: Daniel Weipert Date: Sun, 6 Feb 2022 18:18:23 +0100 Subject: Evacuate building local mount path to function --- lua/rclone.lua | 24 ++++++++++++++++++------ 1 file changed, 18 insertions(+), 6 deletions(-) diff --git a/lua/rclone.lua b/lua/rclone.lua index 0f94916..df7aec6 100644 --- a/lua/rclone.lua +++ b/lua/rclone.lua @@ -151,6 +151,23 @@ local function build_cmd_remote_path(config, remote) return remote .. ':' .. config.vim_rclone_remote_path end +--- +-- Add local mount path +-- +-- @param local_path string +-- @param options table +-- @param config table +-- +-- @return string +local function build_cmd_local_mount_path(local_path, options, config) + local mount_directory = options['directory'] or + config.vim_rclone_mount_directory or + vim.g.vim_rclone_mount_directory or + 'rclone.mount' + + return local_path .. '/' .. mount_directory +end + --- -- Add config location path -- @@ -441,12 +458,7 @@ local function mount(options) local local_path = prepare_cmd_local_path(config) local remote_path = build_cmd_remote_path(config, remote) - - local mount_directory = options['directory'] or - config.vim_rclone_mount_directory or - vim.g.vim_rclone_mount_directory or - 'rclone.mount' - local local_mount_path = local_path .. '/' .. mount_directory + local local_mount_path = build_cmd_local_mount_path(local_path, options, config) local cmd = 'rclone mount ' .. -- cgit v1.2.3