|  |  | @ -24,59 +24,3 @@ vim.api.nvim_create_user_command("ClearBuffers", function() | 
			
		
	
		
			
				
					|  |  |  | vim.cmd('%bd|e#|bd#') | 
			
		
	
		
			
				
					|  |  |  | end, {}) | 
			
		
	
		
			
				
					|  |  |  |  | 
			
		
	
		
			
				
					|  |  |  |  | 
			
		
	
		
			
				
					|  |  |  | local function load_env_file() | 
			
		
	
		
			
				
					|  |  |  | local env_file_path = vim.fn.getcwd() .. "/.env"  -- Construct the path relative to the current working directory | 
			
		
	
		
			
				
					|  |  |  | local env_file = io.open(env_file_path, "r")  -- Open the .env file | 
			
		
	
		
			
				
					|  |  |  |  | 
			
		
	
		
			
				
					|  |  |  | if not env_file then | 
			
		
	
		
			
				
					|  |  |  | print("Could not open .env file") | 
			
		
	
		
			
				
					|  |  |  | return | 
			
		
	
		
			
				
					|  |  |  | end | 
			
		
	
		
			
				
					|  |  |  |  | 
			
		
	
		
			
				
					|  |  |  | for line in env_file:lines() do | 
			
		
	
		
			
				
					|  |  |  | local key, value = line:match("^(%S+)=(%S+)") | 
			
		
	
		
			
				
					|  |  |  | if key and value then | 
			
		
	
		
			
				
					|  |  |  | vim.env[key] = value | 
			
		
	
		
			
				
					|  |  |  | end | 
			
		
	
		
			
				
					|  |  |  | end | 
			
		
	
		
			
				
					|  |  |  | env_file:close() | 
			
		
	
		
			
				
					|  |  |  | end | 
			
		
	
		
			
				
					|  |  |  |  | 
			
		
	
		
			
				
					|  |  |  | local function sync_file_to_sftp() | 
			
		
	
		
			
				
					|  |  |  | load_env_file() | 
			
		
	
		
			
				
					|  |  |  |  | 
			
		
	
		
			
				
					|  |  |  | -- Get SFTP credentials from environment variables | 
			
		
	
		
			
				
					|  |  |  | local sftp_user = os.getenv("SFTP_USER") | 
			
		
	
		
			
				
					|  |  |  | local sftp_host = os.getenv("SFTP_HOST") | 
			
		
	
		
			
				
					|  |  |  | local sftp_port = os.getenv("SFTP_PORT") | 
			
		
	
		
			
				
					|  |  |  | local sftp_password = os.getenv("SFTP_PASSWORD") | 
			
		
	
		
			
				
					|  |  |  | local sftp_theme_directory = os.getenv("SFTP_THEME_DIRECTORY") | 
			
		
	
		
			
				
					|  |  |  |  | 
			
		
	
		
			
				
					|  |  |  | local current_file = vim.fn.expand("%:p")  -- Get the full path of the current file | 
			
		
	
		
			
				
					|  |  |  |  | 
			
		
	
		
			
				
					|  |  |  | -- Define your project root path | 
			
		
	
		
			
				
					|  |  |  | local project_root = vim.fn.getcwd()  -- Current working directory where Neovim was launched | 
			
		
	
		
			
				
					|  |  |  | local relative_path = current_file:sub(#project_root + 1) | 
			
		
	
		
			
				
					|  |  |  |  | 
			
		
	
		
			
				
					|  |  |  | -- Construct the full remote path | 
			
		
	
		
			
				
					|  |  |  | local remote_path = sftp_theme_directory .. relative_path  -- Append the relative path to the remote base path | 
			
		
	
		
			
				
					|  |  |  |  | 
			
		
	
		
			
				
					|  |  |  | -- Command to sync the file using lftp | 
			
		
	
		
			
				
					|  |  |  | local lftp_cmd = string.format( | 
			
		
	
		
			
				
					|  |  |  | "lftp -u %s,%s sftp://%s:%s -e 'put %s -o %s; bye' > /dev/null 2>&1", | 
			
		
	
		
			
				
					|  |  |  | sftp_user, | 
			
		
	
		
			
				
					|  |  |  | sftp_password, | 
			
		
	
		
			
				
					|  |  |  | sftp_host, | 
			
		
	
		
			
				
					|  |  |  | sftp_port, | 
			
		
	
		
			
				
					|  |  |  | current_file, | 
			
		
	
		
			
				
					|  |  |  | remote_path | 
			
		
	
		
			
				
					|  |  |  | ) | 
			
		
	
		
			
				
					|  |  |  |  | 
			
		
	
		
			
				
					|  |  |  | -- Execute the command | 
			
		
	
		
			
				
					|  |  |  | os.execute(lftp_cmd) | 
			
		
	
		
			
				
					|  |  |  | print("File synced to SFTP server: " .. remote_path) | 
			
		
	
		
			
				
					|  |  |  | end | 
			
		
	
		
			
				
					|  |  |  |  | 
			
		
	
		
			
				
					|  |  |  | -- Map the function to a command in Neovim | 
			
		
	
		
			
				
					|  |  |  | vim.api.nvim_create_user_command("SyncToNeto", sync_file_to_sftp, {}) |