summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJeff Zhao <jeff.no.zhao@gmail.com>2022-05-26 19:52:52 -0400
committerJeff Zhao <jeff.no.zhao@gmail.com>2022-05-26 19:52:52 -0400
commit34170bbec4a67dfc3c85ccf890ea0189fe2728ae (patch)
tree92178294231b939ff879ea4f13243d07800e3e1d
parent3181c6d61b5a71c7e408263e85c4d9b67463aa5e (diff)
parent24c21dc9aed80c61ed9bdb72d9597cfbe66fcfaf (diff)
Merge branch 'main' of github.com:kamiyaa/joshuto
-rw-r--r--.github/workflows/clippy.yml27
-rw-r--r--config/keymap.toml1
-rw-r--r--rustfmt.toml1
-rw-r--r--src/commands/open_file.rs23
-rw-r--r--src/commands/zoxide.rs24
-rw-r--r--src/key_command/impl_appexecute.rs2
6 files changed, 50 insertions, 28 deletions
diff --git a/.github/workflows/clippy.yml b/.github/workflows/clippy.yml
new file mode 100644
index 0000000..aee7015
--- /dev/null
+++ b/.github/workflows/clippy.yml
@@ -0,0 +1,27 @@
+name: Clippy - Catch common mistakes and improve your Rust code
+
+on:
+ push:
+ branches: [dev, main]
+ pull_request:
+ branches: [dev, main]
+
+jobs:
+ check:
+ name: Clippy - Catch common mistakes and improve your Rust code
+ runs-on: ubuntu-latest
+ strategy:
+ matrix:
+ rust: [stable]
+ steps:
+ - uses: actions/checkout@v2
+ - name: Install minimal ${{ matrix.rust }} rust
+ uses: actions-rs/toolchain@v1
+ with:
+ override: true
+ profile: minimal
+ components: clippy
+ toolchain: ${{ matrix.rust }}
+ - run: cargo -Vv && rustc -Vv
+ - run: cargo clippy -- --deny clippy::all --warn clippy::cargo
+ if: ${{ matrix.rust == 'stable' }}
diff --git a/config/keymap.toml b/config/keymap.toml
index b5980ea..bbc7705 100644
--- a/config/keymap.toml
+++ b/config/keymap.toml
@@ -10,6 +10,7 @@ keymap = [
{ keys = [ "R" ], command = "reload_dirlist" },
{ keys = [ "z", "h" ], command = "toggle_hidden" },
+ { keys = [ "ctrl+h" ], command = "toggle_hidden" },
{ keys = [ "\t" ], command = "tab_switch 1" },
{ keys = [ "backtab" ], command = "tab_switch -1" },
diff --git a/rustfmt.toml b/rustfmt.toml
new file mode 100644
index 0000000..feeb82e
--- /dev/null
+++ b/rustfmt.toml
@@ -0,0 +1 @@
+# Using defaults as defined at https://github.com/rust-lang/rustfmt/blob/master/Configurations.md
diff --git a/src/commands/open_file.rs b/src/commands/open_file.rs
index 48c0d0b..24acae1 100644
--- a/src/commands/open_file.rs
+++ b/src/commands/open_file.rs
@@ -72,11 +72,11 @@ where
S: AsRef<std::ffi::OsStr>,
{
if option.get_fork() {
- let (child_id, handle) = fork_execute(&option, files, context.clone_event_tx())?;
+ let (child_id, handle) = fork_execute(option, files, context.clone_event_tx())?;
context.worker_context_mut().push_child(child_id, handle);
} else {
backend.terminal_drop();
- execute_and_wait(&option, files)?;
+ execute_and_wait(option, files)?;
backend.terminal_restore()?;
}
Ok(())
@@ -139,20 +139,17 @@ where
}
Ok(n) => {
let option = &options[n];
- open_with_entry(context, backend, option, &files)?;
+ open_with_entry(context, backend, option, files)?;
}
Err(_) => {
let mut args_iter = user_input.split_whitespace();
- match args_iter.next() {
- Some(cmd) => {
- backend.terminal_drop();
- let mut option = AppMimetypeEntry::new(String::from(cmd));
- option.args(args_iter);
- let res = execute_and_wait(&option, files);
- backend.terminal_restore()?;
- res?
- }
- None => {}
+ if let Some(cmd) = args_iter.next() {
+ backend.terminal_drop();
+ let mut option = AppMimetypeEntry::new(String::from(cmd));
+ option.args(args_iter);
+ let res = execute_and_wait(&option, files);
+ backend.terminal_restore()?;
+ res?
}
}
}
diff --git a/src/commands/zoxide.rs b/src/commands/zoxide.rs
index 1abe9f2..9ee1bf6 100644
--- a/src/commands/zoxide.rs
+++ b/src/commands/zoxide.rs
@@ -27,14 +27,12 @@ pub fn zoxide_query(context: &mut AppContext, args: &str) -> JoshutoResult {
context
.message_queue_mut()
.push_info(format!("z {:?}", zoxide_path));
- change_directory::change_directory(context, &path)?;
- }
- } else {
- if let Ok(zoxide_str) = std::str::from_utf8(&zoxide_output.stderr) {
- context
- .message_queue_mut()
- .push_error(zoxide_str.to_string());
+ change_directory::change_directory(context, path)?;
}
+ } else if let Ok(zoxide_str) = std::str::from_utf8(&zoxide_output.stderr) {
+ context
+ .message_queue_mut()
+ .push_error(zoxide_str.to_string());
}
Ok(())
}
@@ -65,14 +63,12 @@ pub fn zoxide_query_interactive(
context
.message_queue_mut()
.push_info(format!("zi {:?}", zoxide_path));
- change_directory::change_directory(context, &path)?;
- }
- } else {
- if let Ok(zoxide_str) = std::str::from_utf8(&zoxide_output.stderr) {
- context
- .message_queue_mut()
- .push_error(zoxide_str.to_string());
+ change_directory::change_directory(context, path)?;
}
+ } else if let Ok(zoxide_str) = std::str::from_utf8(&zoxide_output.stderr) {
+ context
+ .message_queue_mut()
+ .push_error(zoxide_str.to_string());
}
Ok(())
}
diff --git a/src/key_command/impl_appexecute.rs b/src/key_command/impl_appexecute.rs
index 993d3f8..bf2b9fc 100644
--- a/src/key_command/impl_appexecute.rs
+++ b/src/key_command/impl_appexecute.rs
@@ -106,7 +106,7 @@ impl AppExecute for Command {
Self::SearchFzf => search_fzf::search_fzf(context, backend),
Self::SubdirFzf => subdir_fzf::subdir_fzf(context, backend),
- Self::Zoxide(arg) => zoxide::zoxide_query(context, &arg),
+ Self::Zoxide(arg) => zoxide::zoxide_query(context, arg),
Self::ZoxideInteractive => zoxide::zoxide_query_interactive(context, backend),
}
}