diff --git a/komorebi-for-kde/flake.nix b/komorebi-for-kde/flake.nix index a1c4fc83..112c91b2 100644 --- a/komorebi-for-kde/flake.nix +++ b/komorebi-for-kde/flake.nix @@ -53,9 +53,8 @@ toolchain = pkgs.rust-bin.fromRustupToolchainFile ./rust-toolchain.toml; craneLib = (crane.mkLib pkgs).overrideToolchain toolchain; # rustfmt.toml uses options only a nightly rustfmt knows - craneLibFmt = (crane.mkLib pkgs).overrideToolchain ( - pkgs.rust-bin.nightly.latest.minimal.override { extensions = [ "rustfmt" ]; } - ); + fmtToolchain = pkgs.rust-bin.nightly.latest.minimal.override { extensions = [ "rustfmt" ]; }; + craneLibFmt = (crane.mkLib pkgs).overrideToolchain fmtToolchain; # the repository, cut down to this workspace and the crates of the root workspace it depends # on by path (komorebi-layouts and what they depend on, komorebi-themes), with the root @@ -208,6 +207,7 @@ inherit craneLib craneLibFmt + fmtToolchain src real workspaceArgs @@ -339,9 +339,17 @@ }; checks = { - komorebi-workspace-fmt = build.craneLibFmt.cargoFmt ( - build.workspaceArgs // { inherit (build) src; cargoExtraArgs = build.packages; } - ); + # tools/format-all --tree kde: the nightly rustfmt over the files of this tree, file by file. `cargo fmt` + # followed `mod windows;` of the shared entry files into files this source does not have. + komorebi-workspace-fmt = + pkgs.runCommand "komorebi-workspace-fmt" + { + nativeBuildInputs = [ build.fmtToolchain ]; + } + '' + RUSTFMT=rustfmt bash ${builtins.path { path = repoRoot + "/tools/format-all"; name = "format-all"; }} --check --tree kde --root ${build.real} + touch $out + ''; komorebi-workspace-clippy = build.craneLib.cargoClippy ( build.individualCrateArgs @@ -387,8 +395,10 @@ "komorebi-client-macos" "komorebi-bar-macos" "version-macos" - ]; - cargoDenyChecks = "--config ${platformDir}/deny.toml bans licenses sources"; + ] + # --config is an option of `cargo deny`, not of `check`, in the cargo-deny of this flake's nixpkgs + + " --config ${platformDir}/deny.toml"; + cargoDenyChecks = "bans licenses sources"; } ); diff --git a/komorebi-for-kde/komorebi/Cargo.toml b/komorebi-for-kde/komorebi/Cargo.toml index 1d8d0bb1..86c059c7 100644 --- a/komorebi-for-kde/komorebi/Cargo.toml +++ b/komorebi-for-kde/komorebi/Cargo.toml @@ -12,9 +12,13 @@ komorebi-collections = { path = "../../crates/komorebi-collections" } komorebi-core = { path = "../../crates/komorebi-core" } komorebi-layouts = { path = "../../komorebi-layouts", features = ["schemars"] } komorebi-scrolling = { path = "../../komorebi-scrolling" } -komorebi-config = { path = "../../crates/komorebi-config", default-features = false, features = ["schemars"] } +komorebi-config = { path = "../../crates/komorebi-config", default-features = false, features = [ + "schemars", +] } komorebi-settings = { path = "../../crates/komorebi-settings" } -komorebi-protocol = { path = "../../crates/komorebi-protocol", default-features = false, features = ["schemars"] } +komorebi-protocol = { path = "../../crates/komorebi-protocol", default-features = false, features = [ + "schemars", +] } komorebi-transport = { path = "../../crates/komorebi-transport" } version = { package = "version-linux", path = "../version" } @@ -32,7 +36,9 @@ pastey = { version = "0.2" } regex = "1" schemars = { version = "1.1", optional = true } serde = { version = "1", features = ["derive"] } -serde_json = { package = "serde_json_lenient", version = "0.2", features = ["preserve_order"] } +serde_json = { package = "serde_json_lenient", version = "0.2", features = [ + "preserve_order", +] } serde_with = { version = "3", features = ["schemars_1"] } strum = { version = "0.28", features = ["derive"] } tokio = { version = "1", features = [ @@ -57,7 +63,11 @@ uuid = { version = "1", features = ["v4"] } [features] default = ["schemars"] deadlock_detection = ["parking_lot/deadlock_detection"] -schemars = ["dep:schemars", "komorebi-collections/schemars", "komorebi-core/schemars"] +schemars = [ + "dep:schemars", + "komorebi-collections/schemars", + "komorebi-core/schemars", +] [lib] name = "komorebi" diff --git a/komorebi-for-kde/komorebi/src/desktop.rs b/komorebi-for-kde/komorebi/src/desktop.rs index 261efe5f..d92701b2 100644 --- a/komorebi-for-kde/komorebi/src/desktop.rs +++ b/komorebi-for-kde/komorebi/src/desktop.rs @@ -286,8 +286,8 @@ pub fn update_monitor_work_areas(wm: &mut WindowManager) -> eyre::Result<()> { /// are on, so that starting komorebi tiles what is on screen. /// /// Each monitor is first focused on the workspace the compositor shows on it -/// ([`Backend::current_workspaces`]). A window is on the monitor whose bounds contain its middle, -/// and on the workspace whose desktop it is on ([`Backend::window_workspace`]), which need not be +/// (`Backend::current_workspaces`). A window is on the monitor whose bounds contain its middle, +/// and on the workspace whose desktop it is on (`Backend::window_workspace`), which need not be /// the one in front; a window on every desktop goes to the one in front. The monitor gets as many /// workspaces as that takes. A window that is minimized, that komorebi does not manage /// ([`Window::should_manage`]: not a normal window, or one the rules ignore), or that is on no @@ -295,9 +295,6 @@ pub fn update_monitor_work_areas(wm: &mut WindowManager) -> eyre::Result<()> { /// ([`Workspace::adopt_maximized_window`](crate::workspace::Workspace::adopt_maximized_window)), not /// a container. Nothing is moved: tiling is [`WindowManager::retile_all`]'s job. /// -/// [`Backend::current_workspaces`]: crate::backend::Backend::current_workspaces -/// [`Backend::window_workspace`]: crate::backend::Backend::window_workspace -/// /// # Errors /// /// This never returns an error: a window that cannot be placed is skipped. diff --git a/komorebi-for-kde/komorebi/src/kwin/mod.rs b/komorebi-for-kde/komorebi/src/kwin/mod.rs index 468b7b7b..d06e6d25 100644 --- a/komorebi-for-kde/komorebi/src/kwin/mod.rs +++ b/komorebi-for-kde/komorebi/src/kwin/mod.rs @@ -52,8 +52,8 @@ //! When something other than komorebi does either, the script reports it, and the table turns it //! into a [`WorkspaceChange`] or a [`WorkspaceMove`] for the window manager to follow. //! -//! Hiding a window ([`Backend::hide`]) moves it to one more desktop, `komorebi-park`, that nobody -//! looks at and that is not a workspace; [`Backend::restore`] moves it back to the desktop of its +//! Hiding a window (`Backend::hide`) moves it to one more desktop, `komorebi-park`, that nobody +//! looks at and that is not a workspace; `Backend::restore` moves it back to the desktop of its //! workspace. KWin saves its desktops in `kwinrc` as soon as one is made, so a desktop that //! komorebi made and did not remove would be there for every later session: komorebi removes it //! when it stops, and one that an earlier run left (it was killed, or the session was torn down @@ -304,12 +304,12 @@ impl Poll { /// The desktop of a running KWin, read and changed through the script komorebi loads into it. /// /// The queries are answered from a [`state::Table`] that the script's events keep up to date, so -/// they do not wait for KWin, except [`Backend::cursor_pos`]: only the script can read the pointer, +/// they do not wait for KWin, except `Backend::cursor_pos`: only the script can read the pointer, /// so it is asked, and given 250 ms to answer. The table also keeps the frame a window had when the /// user began to drag it, for [`Backend::drag_origin`], and the frame the user asked for when they /// let go of an edge of it, for [`Backend::drag_end`]. /// -/// A command ([`Backend::set_rect`], [`Backend::focus`] and the rest) is queued for the script and +/// A command (`Backend::set_rect`, `Backend::focus` and the rest) is queued for the script and /// returns: the script gets the queue as the answer to its held `Poll` call, and carries the /// commands out in order. Commands queued within a millisecond of each other go out as one batch, /// so a retile reaches KWin at once. A command is an error when the table does not know the @@ -318,7 +318,7 @@ impl Poll { /// /// The script cannot move the pointer, so the pointer follows the focus through KWin's own "Move /// Mouse to Focus" action, over `kglobalaccel`: it lands in the middle of the window KWin has -/// focused, whatever rectangle [`Backend::center_cursor_in`] is given. A KWin without global +/// focused, whatever rectangle `Backend::center_cursor_in` is given. A KWin without global /// shortcuts leaves the pointer where it is. /// /// It is made by [`connect`]. diff --git a/komorebi-for-kde/komorebi/src/monitor.rs b/komorebi-for-kde/komorebi/src/monitor.rs index 44d052bb..fade41a6 100644 --- a/komorebi-for-kde/komorebi/src/monitor.rs +++ b/komorebi-for-kde/komorebi/src/monitor.rs @@ -34,7 +34,7 @@ use serde::Deserialize; use serde::Serialize; use std::sync::atomic::Ordering; -/// The monitor over KDE's [`Window`], which is `komorebi_core::Monitor` with this platform's methods +/// The monitor over KDE's `Window`, which is `komorebi_core::Monitor` with this platform's methods /// added by [`MonitorExt`] pub type Monitor = komorebi_core::Monitor; diff --git a/komorebi-for-kde/komorebi/src/transparency_manager.rs b/komorebi-for-kde/komorebi/src/transparency_manager.rs index 7e6f2ffe..97bcce78 100644 --- a/komorebi-for-kde/komorebi/src/transparency_manager.rs +++ b/komorebi-for-kde/komorebi/src/transparency_manager.rs @@ -98,7 +98,7 @@ pub fn transparent_windows(wm: &WindowManager) -> Vec { /// /// The backend is told only what differs from what it was last told, which the window manager /// keeps in [`WindowManager::opacity_applied`]: windows that should not be see-through any more -/// are made opaque, and the others are given [`TRANSPARENCY_ALPHA`]. With transparency off, every +/// are made opaque, and the others are given `TRANSPARENCY_ALPHA`. With transparency off, every /// window is opaque. A failure is logged. pub fn apply(wm: &mut WindowManager) { // one snapshot, so the flag and the alpha are from the same configuration diff --git a/komorebi-for-kde/komorebi/src/workspace.rs b/komorebi-for-kde/komorebi/src/workspace.rs index 751aea0d..01f42e1a 100644 --- a/komorebi-for-kde/komorebi/src/workspace.rs +++ b/komorebi-for-kde/komorebi/src/workspace.rs @@ -43,7 +43,7 @@ pub use komorebi_core::WorkspaceWindowLocation; pub(crate) use komorebi_core::sorted_layout_options_rules; /// The workspace over KDE's [`Window`], which is `komorebi_core::Workspace` with this platform's -/// methods added by [`WorkspaceExt`] and the scrolling ones of [`WorkspaceScrolling`] +/// methods added by [`WorkspaceExt`] and the scrolling ones of `WorkspaceScrolling` pub type Workspace = komorebi_core::Workspace; /// What only KDE keeps in a workspace diff --git a/komorebi-for-kde/komorebic/Cargo.toml b/komorebi-for-kde/komorebic/Cargo.toml index e4b52128..8d228f58 100644 --- a/komorebi-for-kde/komorebic/Cargo.toml +++ b/komorebi-for-kde/komorebic/Cargo.toml @@ -5,7 +5,9 @@ description = "The command-line interface for Komorebi, a tiling window manager edition = "2024" [dependencies] -komorebi-config = { path = "../../crates/komorebi-config", default-features = false, features = ["schemars"] } +komorebi-config = { path = "../../crates/komorebi-config", default-features = false, features = [ + "schemars", +] } komorebi = { package = "komorebi-linux", path = "../komorebi", default-features = false } komorebi-client = { package = "komorebi-client-linux", path = "../komorebi-client", default-features = false } komorebi-hotkeys = { path = "../komorebi-hotkeys" } diff --git a/tools/format-all b/tools/format-all index 79127f6a..3a6f2228 100755 --- a/tools/format-all +++ b/tools/format-all @@ -15,10 +15,13 @@ # shared crates belong to the kde and mac trees # mac komorebi-for-mac/**/*.rs and the macos modules of the shared crates, with # komorebi-for-mac/rustfmt.toml -# kde `cargo fmt -p `, as komorebi-for-kde/flake.nix does -# The nightly rustfmt is $RUSTFMT if set, else `rustfmt` if that is a nightly, else the one of the -# dev shell of the root flake (`nix develop`), which is the one the nix checks use (a nightly of the -# pinned rust-overlay; another nightly may format a little differently). +# kde komorebi-for-kde/**/*.rs and the linux modules of the shared crates, with +# komorebi-for-kde/rustfmt.toml (the same file-by-file invocation as the mac one; the nix +# check runs this script with the rustfmt of the flake's own nightly, fmtToolchain) +# The nightly rustfmt is $RUSTFMT if set, else the one of the dev shell of the root flake (`nix develop`), +# which is the nightly of the pinned rust-overlay that the nix checks use (the flake of each tree pins the +# same revision; another nightly may format differently and may not follow cfg_select), else a nightly +# `rustfmt` on PATH. set -uo pipefail orig_args=("$@") @@ -39,10 +42,12 @@ done root=$(cd "$root" && pwd) if [ -z "${RUSTFMT:-}" ]; then - if rustfmt --version 2>/dev/null | grep -q nightly; then + if [ -n "${FORMAT_ALL_IN_SHELL:-}" ]; then RUSTFMT=rustfmt - elif [ -z "${FORMAT_ALL_IN_SHELL:-}" ] && command -v nix >/dev/null; then + elif command -v nix >/dev/null; then FORMAT_ALL_IN_SHELL=1 exec nix develop "$root" --command "$0" "${orig_args[@]}" --root "$root" + elif rustfmt --version 2>/dev/null | grep -q nightly; then + RUSTFMT=rustfmt else echo "format-all: no nightly rustfmt (set RUSTFMT)" >&2; exit 2 fi @@ -77,6 +82,7 @@ if [ "$tree" = mac ] || [ "$tree" = all ]; then fi if [ "$tree" = kde ] || [ "$tree" = all ]; then echo "format-all: kde" - cargo fmt -p komorebi -p komorebi-linux -p komorebic -p komorebi-client -p komorebi-hotkeys -- $flag || status=1 + { rs_files | grep '^komorebi-for-kde/'; rs_files | grep -E "^(komorebic/src/linux|komorebic/tests/linux_|komorebi-client/src/linux\.rs|komorebi-client/tests/linux_)"; } \ + | run_rustfmt komorebi-for-kde/rustfmt.toml || status=1 fi exit $status