diff options
author | aszlig <aszlig@nix.build> | 2024-03-25 11:56:56 +0100 |
---|---|---|
committer | aszlig <aszlig@nix.build> | 2024-03-25 12:12:33 +0100 |
commit | ed98f10190876557a0f0fd0d3c91f9745d34d911 (patch) | |
tree | d83ae99981c25d777ed46865e5fca406666298cc | |
parent | 061b9452ca81f2e96373973d4e675f40e92fd7dd (diff) |
vim: Don't rustfmt without an explicit config
This is getting annoying when contributing to external projects that don't have a rustfmt.toml, because I constantly forget to disable it for a buffer and then get a massive diff that I need to revert. My own projects all have a rustfmt.toml anyway, so there really is no reason to do it by default nor have a custom rustfmt config in Vuizvui. Signed-off-by: aszlig <aszlig@nix.build>
-rw-r--r-- | pkgs/aszlig/default.nix | 1 | ||||
-rw-r--r-- | pkgs/aszlig/rustfmt/config.patch | 13 | ||||
-rw-r--r-- | pkgs/aszlig/rustfmt/default.nix | 30 | ||||
-rw-r--r-- | pkgs/aszlig/vim/default.nix | 6 |
4 files changed, 4 insertions, 46 deletions
diff --git a/pkgs/aszlig/default.nix b/pkgs/aszlig/default.nix index 52513103..20dfa2b4 100644 --- a/pkgs/aszlig/default.nix +++ b/pkgs/aszlig/default.nix @@ -16,7 +16,6 @@ psi = callPackage ./psi { }; pvolctrl = callPackage ./pvolctrl { }; radare2 = callPackage ./radare2 { inherit radare2; }; - rustfmt = callPackage ./rustfmt { inherit rustfmt; }; vim = callPackage ./vim { vim = vim-full; }; xterm = callPackage ./xterm { inherit xterm; }; } diff --git a/pkgs/aszlig/rustfmt/config.patch b/pkgs/aszlig/rustfmt/config.patch deleted file mode 100644 index 6864b797..00000000 --- a/pkgs/aszlig/rustfmt/config.patch +++ /dev/null @@ -1,13 +0,0 @@ -diff --git a/src/tools/rustfmt/src/config/mod.rs b/src/tools/rustfmt/src/config/mod.rs -index cd90e090..a6db6da1 100644 ---- a/src/tools/rustfmt/src/config/mod.rs -+++ b/src/tools/rustfmt/src/config/mod.rs -@@ -282,7 +282,7 @@ impl Config { - } - } - -- Ok(None) -+ Ok(Some(env!("DEFAULT_CONFIG_FILE").into())) - } - - match resolve_project_file(dir)? { diff --git a/pkgs/aszlig/rustfmt/default.nix b/pkgs/aszlig/rustfmt/default.nix deleted file mode 100644 index 9ec78bf9..00000000 --- a/pkgs/aszlig/rustfmt/default.nix +++ /dev/null @@ -1,30 +0,0 @@ -{ rustfmt, runCommand, remarshal }: - -let - defaultConfig = { - format_code_in_doc_comments = true; - format_macro_matchers = true; - format_strings = true; - group_imports = "StdExternalCrate"; - match_block_trailing_comma = true; - max_width = 79; - newline_style = "Unix"; - normalize_doc_attributes = true; - overflow_delimited_expr = true; - reorder_impl_items = true; - unstable_features = true; - use_field_init_shorthand = true; - use_try_shorthand = true; - wrap_comments = true; - }; - -in (rustfmt.override { asNightly = true; }).overrideAttrs (drv: { - patches = (drv.patches or []) ++ [ ./config.patch ]; - DEFAULT_CONFIG_FILE = runCommand "rustfmt.conf" { - nativeBuildInputs = [ remarshal ]; - value = builtins.toJSON defaultConfig; - passAsFile = [ "value" ]; - } '' - json2toml "$valuePath" "$out" - ''; -}) diff --git a/pkgs/aszlig/vim/default.nix b/pkgs/aszlig/vim/default.nix index 4bbc8107..641c39ea 100644 --- a/pkgs/aszlig/vim/default.nix +++ b/pkgs/aszlig/vim/default.nix @@ -604,8 +604,10 @@ let if !executable('rustc') let g:rustc_path = '${rustc}/bin/rustc' endif - let g:rustfmt_command = '${rustfmt}/bin/rustfmt' - let g:rustfmt_autosave = 1 + let g:rustfmt_command = '${rustfmt.override { + asNightly = true; + }}/bin/rustfmt' + let g:rustfmt_autosave_if_config_present = 1 let g:rust_recommended_style = 0 ''; |