summaryrefslogtreecommitdiffstats
path: root/src/config
diff options
context:
space:
mode:
authorJiayi Zhao <jeff.no.zhao@gmail.com>2019-02-19 17:43:13 -0500
committerJiayi Zhao <jeff.no.zhao@gmail.com>2019-02-19 17:43:25 -0500
commit0be734a6d7154573d8e570980f0af27ac5cb8190 (patch)
tree76789bee4f068ba000a13921ae5caec0a8c4cabe /src/config
parent348ef3c36115ac7060f141c27157b6b2f5c91f37 (diff)
rust 2018 and clippy
Diffstat (limited to 'src/config')
-rw-r--r--src/config/config.rs10
-rw-r--r--src/config/keymap.rs43
-rw-r--r--src/config/mimetype.rs8
-rw-r--r--src/config/mod.rs6
-rw-r--r--src/config/preview.rs8
-rw-r--r--src/config/theme.rs8
6 files changed, 34 insertions, 49 deletions
diff --git a/src/config/config.rs b/src/config/config.rs
index f6adb04..6bfa627 100644
--- a/src/config/config.rs
+++ b/src/config/config.rs
@@ -1,11 +1,9 @@
-extern crate toml;
-extern crate whoami;
-extern crate xdg;
+use serde_derive::Deserialize;
-use config::{parse_config_file, Flattenable};
-use sort;
+use crate::config::{parse_config_file, Flattenable};
+use crate::sort;
-use CONFIG_FILE;
+use crate::CONFIG_FILE;
#[derive(Clone, Debug, Deserialize)]
pub struct SortRawOption {
diff --git a/src/config/keymap.rs b/src/config/keymap.rs
index 83e48e4..eb0c81c 100644
--- a/src/config/keymap.rs
+++ b/src/config/keymap.rs
@@ -1,13 +1,10 @@
-extern crate fs_extra;
-extern crate toml;
-extern crate xdg;
-
+use serde_derive::Deserialize;
use std::collections::HashMap;
use std::process::exit;
-use commands;
-use config::{parse_config_file, Flattenable};
-use KEYMAP_FILE;
+use crate::commands;
+use crate::config::{parse_config_file, Flattenable};
+use crate::KEYMAP_FILE;
pub const BACKSPACE: i32 = 0x7F;
pub const TAB: i32 = 0x9;
@@ -73,25 +70,23 @@ fn insert_keycommand(
if let Some(s) = key_to_i32(&keys[0]) {
map.insert(s, commands::CommandKeybind::SimpleKeybind(keycommand));
}
- } else {
- if let Some(s) = key_to_i32(&keys[0]) {
- let mut new_map: HashMap<i32, commands::CommandKeybind>;
- match map.remove(&s) {
- Some(commands::CommandKeybind::CompositeKeybind(mut m)) => {
- new_map = m;
- }
- Some(_) => {
- eprintln!("Error: Keybindings ambiguous");
- exit(1);
- }
- None => {
- new_map = HashMap::new();
- }
+ } else if let Some(s) = key_to_i32(&keys[0]) {
+ let mut new_map: HashMap<i32, commands::CommandKeybind>;
+ match map.remove(&s) {
+ Some(commands::CommandKeybind::CompositeKeybind(m)) => {
+ new_map = m;
+ }
+ Some(_) => {
+ eprintln!("Error: Keybindings ambiguous");
+ exit(1);
+ }
+ None => {
+ new_map = HashMap::new();
}
- insert_keycommand(&mut new_map, keycommand, &keys[1..]);
- let composite_command = commands::CommandKeybind::CompositeKeybind(new_map);
- map.insert(s as i32, composite_command);
}
+ insert_keycommand(&mut new_map, keycommand, &keys[1..]);
+ let composite_command = commands::CommandKeybind::CompositeKeybind(new_map);
+ map.insert(s as i32, composite_command);
}
}
diff --git a/src/config/mimetype.rs b/src/config/mimetype.rs
index 256aa9e..8c730c0 100644
--- a/src/config/mimetype.rs
+++ b/src/config/mimetype.rs
@@ -1,11 +1,9 @@
-extern crate toml;
-extern crate xdg;
-
+use serde_derive::Deserialize;
use std::collections::HashMap;
use std::fmt;
-use config::{parse_config_file, Flattenable};
-use MIMETYPE_FILE;
+use crate::config::{parse_config_file, Flattenable};
+use crate::MIMETYPE_FILE;
#[derive(Debug, Deserialize)]
pub struct JoshutoMimetypeEntry {
diff --git a/src/config/mod.rs b/src/config/mod.rs
index 273b9ab..dca9f3d 100644
--- a/src/config/mod.rs
+++ b/src/config/mod.rs
@@ -1,5 +1,3 @@
-extern crate serde;
-
pub mod config;
pub mod keymap;
pub mod mimetype;
@@ -12,11 +10,11 @@ pub use self::mimetype::JoshutoMimetype;
pub use self::preview::JoshutoPreview;
pub use self::theme::{JoshutoColorTheme, JoshutoTheme};
-use self::serde::de::DeserializeOwned;
+use serde::de::DeserializeOwned;
use std::fs;
use std::path::{Path, PathBuf};
-use CONFIG_HIERARCHY;
+use crate::CONFIG_HIERARCHY;
// implemented by config file implementations to turn a RawConfig into a Config
trait Flattenable<T> {
diff --git a/src/config/preview.rs b/src/config/preview.rs
index b24e5c9..939c45f 100644
--- a/src/config/preview.rs
+++ b/src/config/preview.rs
@@ -1,10 +1,8 @@
-extern crate toml;
-extern crate xdg;
-
+use serde_derive::Deserialize;
use std::collections::HashMap;
-use config::{parse_config_file, Flattenable};
-use PREVIEW_FILE;
+use crate::config::{parse_config_file, Flattenable};
+use crate::PREVIEW_FILE;
#[derive(Debug, Deserialize)]
pub struct JoshutoPreviewEntry {
diff --git a/src/config/theme.rs b/src/config/theme.rs
index 0c43ed8..31ccbdc 100644
--- a/src/config/theme.rs
+++ b/src/config/theme.rs
@@ -1,9 +1,7 @@
-extern crate toml;
-extern crate xdg;
-
+use serde_derive::Deserialize;
use std::collections::HashMap;
-use config::{parse_config_file, Flattenable};
+use crate::config::{parse_config_file, Flattenable};
#[derive(Debug, Deserialize, Clone)]
pub struct JoshutoColorPair {
@@ -224,7 +222,7 @@ impl JoshutoTheme {
}
pub fn get_config() -> JoshutoTheme {
- parse_config_file::<JoshutoRawTheme, JoshutoTheme>(::THEME_FILE)
+ parse_config_file::<JoshutoRawTheme, JoshutoTheme>(crate::THEME_FILE)
.unwrap_or_else(JoshutoTheme::new)
}
}