summaryrefslogtreecommitdiffstats
path: root/src/config/keymap
diff options
context:
space:
mode:
authorJeff Zhao <jeff.no.zhao@gmail.com>2021-10-27 23:50:20 -0400
committerJeff Zhao <jeff.no.zhao@gmail.com>2021-10-27 23:50:20 -0400
commitd27c2980547dbdce01d7a26baf1c1f0ec0a14637 (patch)
tree5e55beac9746a6c069151545c64a9da5214f6eab /src/config/keymap
parentb970793bc9ca190fbd169dfee683c2e853885437 (diff)
remove default config hardcode and use include_str! instead
- this fixes the default config not working
Diffstat (limited to 'src/config/keymap')
-rw-r--r--src/config/keymap/default_keymap.rs100
-rw-r--r--src/config/keymap/keymapping.rs5
2 files changed, 8 insertions, 97 deletions
diff --git a/src/config/keymap/default_keymap.rs b/src/config/keymap/default_keymap.rs
index a8ede07..281e42d 100644
--- a/src/config/keymap/default_keymap.rs
+++ b/src/config/keymap/default_keymap.rs
@@ -1,97 +1,5 @@
-pub const DEFAULT_KEYMAP: &str = "
-mapcommand = [
- { keys = [ \"T\" ], command = \"new_tab\" },
- { keys = [ \"ctrl+t\" ], command = \"new_tab\" },
- { keys = [ \"W\" ], command = \"close_tab\" },
- { keys = [ \"ctrl+w\" ], command = \"close_tab\" },
- { keys = [ \"q\" ], command = \"close_tab\" },
- { keys = [ \"Q\" ], command = \"quit_to_cwd\" },
+#[cfg(not(target_os = "windows"))]
+pub const DEFAULT_KEYMAP: &str = include_str!("../../../config/keymap.toml");
- { keys = [ \"R\" ], command = \"reload_dirlist\" },
- { keys = [ \"z\", \"h\" ], command = \"toggle_hidden\" },
- { keys = [ \"\t\" ], command = \"tab_switch 1\" },
- { keys = [ \"backtab\" ], command = \"tab_switch -1\" },
-
- { keys = [ \"alt+1\" ], command = \"tab_switch_index 1\" },
- { keys = [ \"alt+2\" ], command = \"tab_switch_index 2\" },
- { keys = [ \"alt+3\" ], command = \"tab_switch_index 3\" },
- { keys = [ \"alt+4\" ], command = \"tab_switch_index 4\" },
- { keys = [ \"alt+5\" ], command = \"tab_switch_index 5\" },
-
- # arrow keys
- { keys = [ \"arrow_up\" ], command = \"cursor_move_up\" },
- { keys = [ \"arrow_down\" ], command = \"cursor_move_down\" },
- { keys = [ \"arrow_left\" ], command = \"cd ..\" },
- { keys = [ \"arrow_right\" ], command = \"open\" },
- { keys = [ \"\n\" ], command = \"open\" },
- { keys = [ \"end\" ], command = \"cursor_move_end\" },
- { keys = [ \"home\" ], command = \"cursor_move_home\" },
- { keys = [ \"page_up\" ], command = \"cursor_move_page_up\" },
- { keys = [ \"page_down\" ], command = \"cursor_move_page_down\" },
-
- # vim-like keybindings
- { keys = [ \"j\" ], command = \"cursor_move_down\" },
- { keys = [ \"k\" ], command = \"cursor_move_up\" },
- { keys = [ \"h\" ], command = \"cd ..\" },
- { keys = [ \"l\" ], command = \"open\" },
- { keys = [ \"g\", \"g\" ], command = \"cursor_move_home\" },
- { keys = [ \"G\" ], command = \"cursor_move_end\" },
- { keys = [ \"r\" ], command = \"open_with\" },
-
- { keys = [ \"[\" ], command = \"parent_cursor_move_up\" },
- { keys = [ \"]\" ], command = \"parent_cursor_move_down\" },
-
- { keys = [ \"c\", \"d\" ], command = \":cd \" },
- { keys = [ \"d\", \"d\" ], command = \"cut_files\" },
- { keys = [ \"y\", \"y\" ], command = \"copy_files\" },
- { keys = [ \"p\", \"p\" ], command = \"paste_files\" },
- { keys = [ \"p\", \"o\" ], command = \"paste_files --overwrite=true\" },
-
- { keys = [ \"y\", \"n\" ], command = \"copy_filename\" },
- { keys = [ \"y\", \".\" ], command = \"copy_filename_without_extension\" },
- { keys = [ \"y\", \"p\" ], command = \"copy_filepath\" },
- { keys = [ \"y\", \"d\" ], command = \"copy_dirpath\" },
-
- { keys = [ \"delete\" ], command = \"delete_files\" },
- { keys = [ \"d\", \"D\" ], command = \"delete_files\" },
-
- { keys = [ \"a\" ], command = \"rename_append\" },
- { keys = [ \"A\" ], command = \"rename_prepend\" },
-
- { keys = [ \"f\", \"t\" ], command = \":touch \" },
-
- { keys = [ \" \" ], command = \"select --toggle=true\" },
- { keys = [ \"t\" ], command = \"select --all=true --toggle=true\" },
-
- { keys = [ \"w\" ], command = \"show_workers --exit-key=w\" },
- { keys = [ \"b\", \"b\" ], command = \"bulk_rename\" },
- { keys = [ \"=\" ], command = \"set_mode\" },
-
- { keys = [ \":\" ], command = \":\" },
- { keys = [ \";\" ], command = \":\" },
-
- { keys = [ \"'\" ], command = \":shell \" },
- { keys = [ \"m\", \"k\" ], command = \":mkdir \" },
- { keys = [ \"c\", \"w\" ], command = \":rename \" },
-
- { keys = [ \"/\" ], command = \":search \" },
- { keys = [ \"\\\" ], command = \":search_glob \" },
- { keys = [ \"S\" ], command = \"search_fzf\" },
-
- { keys = [ \"n\" ], command = \"search_next\" },
- { keys = [ \"N\" ], command = \"search_prev\" },
-
- { keys = [ \"s\", \"r\" ], command = \"sort reverse\" },
- { keys = [ \"s\", \"l\" ], command = \"sort lexical\" },
- { keys = [ \"s\", \"m\" ], command = \"sort mtime\" },
- { keys = [ \"s\", \"n\" ], command = \"sort natural\" },
- { keys = [ \"s\", \"s\" ], command = \"sort size\" },
- { keys = [ \"s\", \"e\" ], command = \"sort ext\" },
-
- { keys = [ \"g\", \"r\" ], command = \"cd /\" },
- { keys = [ \"g\", \"c\" ], command = \"cd ~/.config\" },
- { keys = [ \"g\", \"d\" ], command = \"cd ~/Downloads\" },
- { keys = [ \"g\", \"e\" ], command = \"cd /etc\" },
- { keys = [ \"g\", \"h\" ], command = \"cd ~/\" },
- { keys = [ \"?\" ], command = \"help\" }
-]";
+#[cfg(target_os = "windows")]
+pub const DEFAULT_KEYMAP: &str = include_str!("..\\..\\..\\config\\keymap.toml");
diff --git a/src/config/keymap/keymapping.rs b/src/config/keymap/keymapping.rs
index 79fd684..23608f0 100644
--- a/src/config/keymap/keymapping.rs
+++ b/src/config/keymap/keymapping.rs
@@ -91,7 +91,10 @@ impl From<AppKeyMappingCrude> for AppKeyMapping {
impl TomlConfigFile for AppKeyMapping {
fn get_config(file_name: &str) -> Self {
parse_to_config_file::<AppKeyMappingCrude, AppKeyMapping>(file_name)
- .unwrap_or_else(Self::default)
+ .unwrap_or_else(|| {
+ eprintln!("Using default keymapping");
+ Self::default()
+ })
}
}