Fix linting errors

pull/535/head
Arijit Basu 1 year ago committed by Arijit Basu
parent 76224c42e1
commit 053615b041

@ -0,0 +1 @@
use flake

3
.gitignore vendored

@ -14,3 +14,6 @@ book/
.idea/ .idea/
.venv/ .venv/
# direnv
.direnv/

@ -12,7 +12,13 @@
outputs = { self, nixpkgs, nix, ... }: outputs = { self, nixpkgs, nix, ... }:
let let
systems = [ "x86_64-linux" "i686-linux" "x86_64-darwin" "aarch64-linux" "aarch64-darwin" ]; systems = [
"x86_64-linux"
"i686-linux"
"x86_64-darwin"
"aarch64-linux"
"aarch64-darwin"
];
forAllSystems = f: builtins.listToAttrs (map (name: { inherit name; value = f name; }) systems); forAllSystems = f: builtins.listToAttrs (map (name: { inherit name; value = f name; }) systems);
in in
{ {
@ -28,7 +34,30 @@
lockFile = ./Cargo.lock; lockFile = ./Cargo.lock;
}; };
}; };
}); }
);
defaultPackage = forAllSystems (system: self.packages.${system}.xplr); defaultPackage = forAllSystems (system: self.packages.${system}.xplr);
devShells = forAllSystems (system:
let
pkgs = import nixpkgs { inherit system; };
devRequirements = with pkgs; [
gcc
gnumake
clippy
rustc
cargo
rustfmt
rust-analyzer
];
in
{
default = pkgs.mkShell {
RUST_BACKTRACE = 1;
buildInputs = devRequirements;
packages = devRequirements;
};
}
);
}; };
} }

@ -305,7 +305,7 @@ impl App {
let hostname = gethostname().to_string_lossy().to_string(); let hostname = gethostname().to_string_lossy().to_string();
if let Some(vroot) = vroot.as_ref() { if let Some(vroot) = vroot.as_ref() {
if !pwd.starts_with(&vroot) { if !pwd.starts_with(vroot) {
bail!( bail!(
"{:?} is outside of virtual root {:?}", "{:?} is outside of virtual root {:?}",
pwd.to_string_lossy(), pwd.to_string_lossy(),
@ -822,7 +822,7 @@ impl App {
let dir = PathBuf::from(dir).absolutize()?.to_path_buf(); let dir = PathBuf::from(dir).absolutize()?.to_path_buf();
if let Some(vroot) = &self.vroot.clone() { if let Some(vroot) = &self.vroot.clone() {
if !dir.starts_with(&vroot) { if !dir.starts_with(vroot) {
return self.log_error(format!( return self.log_error(format!(
"{:?} is outside of virtual root {:?}", "{:?} is outside of virtual root {:?}",
dir.to_string_lossy(), dir.to_string_lossy(),
@ -1742,7 +1742,7 @@ impl App {
pub fn write_pipes(&self, delimiter: char) -> Result<()> { pub fn write_pipes(&self, delimiter: char) -> Result<()> {
fs::create_dir_all(self.pipe.path.clone())?; fs::create_dir_all(self.pipe.path.clone())?;
fs::write(&self.pipe.msg_in, &[delimiter as u8])?; fs::write(&self.pipe.msg_in, [delimiter as u8])?;
let selection_str = self.selection_str(delimiter); let selection_str = self.selection_str(delimiter);
fs::write(&self.pipe.selection_out, selection_str)?; fs::write(&self.pipe.selection_out, selection_str)?;

@ -15,7 +15,7 @@ lazy_static! {
} }
pub fn explore(parent: &PathBuf, config: &ExplorerConfig) -> Result<Vec<Node>> { pub fn explore(parent: &PathBuf, config: &ExplorerConfig) -> Result<Vec<Node>> {
let dirs = fs::read_dir(&parent)?; let dirs = fs::read_dir(parent)?;
let mut nodes = dirs let mut nodes = dirs
.filter_map(|d| { .filter_map(|d| {
d.ok().map(|e| { d.ok().map(|e| {

@ -197,7 +197,7 @@ impl std::fmt::Display for Key {
_ => c.to_string(), _ => c.to_string(),
}) })
.unwrap_or_else(|| { .unwrap_or_else(|| {
serde_yaml::to_value(&self) serde_yaml::to_value(self)
.ok() .ok()
.and_then(|v| v.as_str().map(|v| v.to_string())) .and_then(|v| v.as_str().map(|v| v.to_string()))
.unwrap_or_default() .unwrap_or_default()

@ -14,7 +14,7 @@ fn mime_essence(path: &Path, is_dir: bool) -> String {
if is_dir { if is_dir {
String::from("inode/directory") String::from("inode/directory")
} else { } else {
mime_guess::from_path(&path) mime_guess::from_path(path)
.first() .first()
.map(|m| m.essence_str().to_string()) .map(|m| m.essence_str().to_string())
.unwrap_or_default() .unwrap_or_default()

@ -60,7 +60,7 @@ pub fn read_all(pipe: &str, delimiter: char) -> Result<Vec<ExternalMsg>> {
.read(true) .read(true)
.write(true) .write(true)
.create(false) .create(false)
.open(&pipe)?; .open(pipe)?;
let mut in_str = String::new(); let mut in_str = String::new();
file.read_to_string(&mut in_str)?; file.read_to_string(&mut in_str)?;

@ -28,7 +28,7 @@ use tui_input::Input;
pub fn get_tty() -> Result<fs::File> { pub fn get_tty() -> Result<fs::File> {
let tty = "/dev/tty"; let tty = "/dev/tty";
match fs::OpenOptions::new().read(true).write(true).open(&tty) { match fs::OpenOptions::new().read(true).write(true).open(tty) {
Ok(f) => Ok(f), Ok(f) => Ok(f),
Err(e) => { Err(e) => {
bail!(format!("Failed to open {}. {}", tty, e)) bail!(format!("Failed to open {}. {}", tty, e))
@ -323,6 +323,7 @@ impl Runner {
let backend = CrosstermBackend::new(stdout); let backend = CrosstermBackend::new(stdout);
let mut terminal = Terminal::new(backend)?; let mut terminal = Terminal::new(backend)?;
terminal.hide_cursor()?; terminal.hide_cursor()?;
terminal.clear()?;
// Threads // Threads
pwd_watcher::keep_watching(app.pwd.as_ref(), tx_msg_in.clone(), rx_pwd_watcher)?; pwd_watcher::keep_watching(app.pwd.as_ref(), tx_msg_in.clone(), rx_pwd_watcher)?;
@ -334,7 +335,7 @@ impl Runner {
tx_msg_in.send(app::Task::new(app::MsgIn::External(msg.clone()), None))?; tx_msg_in.send(app::Task::new(app::MsgIn::External(msg.clone()), None))?;
} }
// Refresh once after loading // Refresh screen once after loading
tx_msg_in.send(app::Task::new( tx_msg_in.send(app::Task::new(
app::MsgIn::External(app::ExternalMsg::Refresh), app::MsgIn::External(app::ExternalMsg::Refresh),
None, None,

@ -809,27 +809,19 @@ fn draw_input_buffer<B: Backend>(
.to_owned() .to_owned()
.extend(&panel_config.input_and_logs); .extend(&panel_config.input_and_logs);
let cursor_offset_left = if config let cursor_offset_left = config
.borders .borders
.as_ref() .as_ref()
.map(|b| b.contains(&Border::Left)) .map(|b| b.contains(&Border::Left))
.unwrap_or(false) .unwrap_or(false) as u16
{ + app.input.prompt.chars().count() as u16;
1
} else {
0
} + app.input.prompt.chars().count() as u16;
let cursor_offset_right = if config let cursor_offset_right = config
.borders .borders
.as_ref() .as_ref()
.map(|b| b.contains(&Border::Right)) .map(|b| b.contains(&Border::Right))
.unwrap_or(false) .unwrap_or(false) as u16
{ + 1;
2
} else {
1
};
let offset_width = cursor_offset_left + cursor_offset_right; let offset_width = cursor_offset_left + cursor_offset_right;
let width = layout_size.width.max(offset_width) - offset_width; let width = layout_size.width.max(offset_width) - offset_width;

Loading…
Cancel
Save