From 8fbac3c232691c18c410ad7e80f4f2108b3a8163 Mon Sep 17 00:00:00 2001 From: Benedikt Peetz Date: Sun, 27 Apr 2025 21:40:18 +0200 Subject: pkgs/lf-make-map: Use trinitrix's keymaps library The library was largely modelled after the previously used `MappingTrie`. Thus using that results in code deduplication. --- .../lf/lf-make-map/src/mapping/lf_mapping.rs | 35 ++++++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100644 pkgs/by-name/lf/lf-make-map/src/mapping/lf_mapping.rs (limited to 'pkgs/by-name/lf/lf-make-map/src/mapping/lf_mapping.rs') diff --git a/pkgs/by-name/lf/lf-make-map/src/mapping/lf_mapping.rs b/pkgs/by-name/lf/lf-make-map/src/mapping/lf_mapping.rs new file mode 100644 index 00000000..f8a6182e --- /dev/null +++ b/pkgs/by-name/lf/lf-make-map/src/mapping/lf_mapping.rs @@ -0,0 +1,35 @@ +// nixos-config - My current NixOS configuration +// +// Copyright (C) 2025 Benedikt Peetz +// SPDX-License-Identifier: GPL-3.0-or-later +// +// This file is part of my nixos-config. +// +// You should have received a copy of the License along with this program. +// If not, see . + +use std::path::PathBuf; + +use crate::mapping::MapKey; + +use super::MappingsTrie; + +impl MappingsTrie { + pub fn to_lf_mappings(&self, home_path: PathBuf) -> String { + let mut raw = self + .0 + .iter() + .map(|(key, value)| { + format!( + "map g{} cd \"{}\"\n", + MapKey::display(&key), + home_path.join(&value.path).display() + ) + }) + .collect::>(); + + raw.sort(); + + raw.into_iter().collect() + } +} -- cgit 1.4.1