From 17cf4485a917c5e7490c0e1a26cdf348f06bf486 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vuka=C5=A1in=20Vojinovi=C4=87?= <150025636+git-f0x@users.noreply.github.com> Date: Tue, 28 Apr 2026 17:55:23 +0200 Subject: [PATCH] chore(rustfmt): change `imports_granularity` to `"Module"` Also includes a Zed config. --- .zed/settings.json | 15 +++++++++++++++ .rustfmt.toml => rustfmt.toml | 2 +- src/comp.rs | 20 +++++++++++--------- src/main.rs | 30 ++++++++++++++++-------------- src/notifications.rs | 13 +++++++------ src/systemd.rs | 14 +++++--------- 6 files changed, 55 insertions(+), 39 deletions(-) create mode 100644 .zed/settings.json rename .rustfmt.toml => rustfmt.toml (90%) diff --git a/.zed/settings.json b/.zed/settings.json new file mode 100644 index 0000000..2cc7b98 --- /dev/null +++ b/.zed/settings.json @@ -0,0 +1,15 @@ +{ + "format_on_save": "on", + "lsp": { + "rust-analyzer": { + "initialization_options": { + "check": { + "command": "clippy", + }, + "rustfmt": { + "extraArgs": ["+nightly"], + }, + }, + }, + }, +} diff --git a/.rustfmt.toml b/rustfmt.toml similarity index 90% rename from .rustfmt.toml rename to rustfmt.toml index 5d9904b..cac8fe8 100644 --- a/.rustfmt.toml +++ b/rustfmt.toml @@ -4,7 +4,7 @@ use_field_init_shorthand = true # Unstable formatting options below; remove if you REALLY don't wanna use `cargo +nightly fmt` format_code_in_doc_comments = true format_strings = true -imports_granularity = "Crate" +imports_granularity = "Module" normalize_comments = true reorder_impl_items = true wrap_comments = true diff --git a/src/comp.rs b/src/comp.rs index d4f5861..8457d08 100644 --- a/src/comp.rs +++ b/src/comp.rs @@ -1,17 +1,19 @@ // SPDX-License-Identifier: GPL-3.0-only use color_eyre::eyre::{Result, WrapErr}; -use launch_pad::{ProcessManager, process::Process}; +use launch_pad::ProcessManager; +use launch_pad::process::Process; use serde::{Deserialize, Serialize}; -use std::{collections::HashMap, os::unix::prelude::*}; -use tokio::{ - io::AsyncReadExt, - net::{UnixStream, unix::OwnedReadHalf}, - sync::{mpsc, oneshot}, - task::JoinHandle, -}; +use std::collections::HashMap; +use std::os::unix::prelude::*; +use tokio::io::AsyncReadExt; +use tokio::net::UnixStream; +use tokio::net::unix::OwnedReadHalf; +use tokio::sync::{mpsc, oneshot}; +use tokio::task::JoinHandle; use tokio_util::sync::CancellationToken; -use crate::{process::mark_as_not_cloexec, service::SessionRequest}; +use crate::process::mark_as_not_cloexec; +use crate::service::SessionRequest; #[derive(Debug, Serialize, Deserialize)] #[serde(rename_all = "snake_case", tag = "message")] diff --git a/src/main.rs b/src/main.rs index 26d4c79..07461b8 100644 --- a/src/main.rs +++ b/src/main.rs @@ -9,30 +9,32 @@ mod process; mod service; mod systemd; -use color_eyre::{Result, eyre::WrapErr}; -use launch_pad::{ProcessManager, process::Process}; +use color_eyre::Result; +use color_eyre::eyre::WrapErr; +use launch_pad::ProcessManager; +use launch_pad::process::Process; use service::SessionRequest; +use std::borrow::Cow; #[cfg(feature = "autostart")] use std::collections::HashSet; +use std::env; +use std::os::fd::AsRawFd; #[cfg(feature = "autostart")] use std::path::PathBuf; #[cfg(feature = "autostart")] use std::process::{Command, Stdio}; -use std::{borrow::Cow, env, os::fd::AsRawFd, sync::Arc}; +use std::sync::Arc; #[cfg(feature = "systemd")] use systemd::{get_systemd_env, is_systemd_used, spawn_scope}; -use tokio::{ - signal::unix::{SignalKind, signal}, - sync::{ - Mutex, - mpsc::{Receiver, Sender}, - oneshot, - }, - time::Duration, -}; +use tokio::signal::unix::{SignalKind, signal}; +use tokio::sync::mpsc::{Receiver, Sender}; +use tokio::sync::{Mutex, oneshot}; +use tokio::time::Duration; use tokio_util::sync::CancellationToken; -use tracing::{Instrument, metadata::LevelFilter}; -use tracing_subscriber::{EnvFilter, fmt, prelude::*}; +use tracing::Instrument; +use tracing::metadata::LevelFilter; +use tracing_subscriber::prelude::*; +use tracing_subscriber::{EnvFilter, fmt}; use crate::notifications::{ DAEMON_NOTIFICATIONS_FD, PANEL_NOTIFICATIONS_FD, notifications_process, diff --git a/src/notifications.rs b/src/notifications.rs index 336a2ce..3ac80f6 100644 --- a/src/notifications.rs +++ b/src/notifications.rs @@ -1,10 +1,11 @@ -use color_eyre::{Result, eyre::Context}; -use launch_pad::{ProcessKey, process::Process}; +use color_eyre::Result; +use color_eyre::eyre::Context; +use launch_pad::ProcessKey; +use launch_pad::process::Process; use rustix::fd::AsRawFd; -use std::{ - os::{fd::OwnedFd, unix::net::UnixStream}, - sync::Arc, -}; +use std::os::fd::OwnedFd; +use std::os::unix::net::UnixStream; +use std::sync::Arc; use tokio::sync::Mutex; use tracing::Instrument; diff --git a/src/systemd.rs b/src/systemd.rs index a155df0..cbf64d5 100644 --- a/src/systemd.rs +++ b/src/systemd.rs @@ -1,15 +1,11 @@ // SPDX-License-Identifier: GPL-3.0-only -use std::{ - path::Path, - process::{Command, Stdio}, - sync::OnceLock, -}; +use std::path::Path; +use std::process::{Command, Stdio}; +use std::sync::OnceLock; -use zbus::{ - Connection, - zvariant::{Array, OwnedValue}, -}; +use zbus::Connection; +use zbus::zvariant::{Array, OwnedValue}; #[derive(Debug)] pub struct EnvVar {