Skip to content

Support multiword aliases as check commands #19765

Description

@mi2ebi

I have this alias in ~/.cargo/config.toml:

[alias]
nitpick = """clippy --
  -W clippy::pedantic
  -A clippy::must_use_candidate
  -W clippy::nursery
  -A clippy::cognitive_complexity
  -A clippy::missing_const_for_fn
  -W clippy::decimal_literal_representation
  -W clippy::deref_by_slicing
  -W clippy::if_then_some_else_none
  -W clippy::lossy_float_literal
  -W clippy::missing_asserts_for_indexing
  -W clippy::needless_raw_strings
  -W clippy::precedence_bits
  -W clippy::print_stderr
  -W clippy::rest_pat_in_fully_bound_structs
  -W clippy::same_name_method
  -W clippy::semicolon_inside_block
  -W clippy::unused_trait_names
"""

and these Helix settings:

[[language]]
name = "rust"
scope = "source.rust"
roots = ["Cargo.toml", "cargo.lock"]
language-servers = ["rust-analyzer"]
auto-format = true

[language-server.rust-analyzer.config]
check = {command = "nitpick"}
cargo = {features = "all"}

Running cargo nitpick myself on a file like

fn main() {
    println!("Hello, world!");
    let b = if true { 1 } else { 0 };
}

correctly outputs

warning: unused variable: `b`
 --> src/main.rs:3:9
  |
3 |     let b = if true { 1 } else { 0 };
  |         ^ help: if this is intentional, prefix it with an underscore: `_b`
  |
  = note: `#[warn(unused_variables)]` on by default

warning: boolean to int conversion using if
 --> src/main.rs:3:13
  |
3 |     let b = if true { 1 } else { 0 };
  |             ^^^^^^^^^^^^^^^^^^^^^^^^ help: replace with from: `i32::from(true)`
  |
  = note: `true as i32` or `true.into()` can also be valid options
  = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#bool_to_int_with_if
  = note: `-W clippy::bool-to-int-with-if` implied by `-W clippy::pedantic`
  = help: to override `-W clippy::pedantic` add `#[allow(clippy::bool_to_int_with_if)]`

But when Helix tries to run rust-analyzer's check, it says (followed by some other stuff that doesn't fit)

Cargo check failed to start: Cargo watcher failed, the command produced no valid metadata (exit code: ExitStatus(unix_wait_status(25856))

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-supportCategory: support questions

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions