highlight: Fix Rust signature parameter styling

2df69b8d96e2aebcf493d1b7194c3eb5e1e1ec24
Rust function signatures were tokenizing lowercase parameter names as
generic variables, which matched the diff theme's Rust
function-definition variable rule and painted large parameter lists red.

Assisted-by: Codex:gpt-5.5
Alexis Sellier committed ago 1 parent 980c3791
crates/diff/src/highlight.rs +0 -0
a.css +0 -0
a.rs\n", +0 -0
crates/diff/src/themes/rustik-catppuccin-mocha.json +6 -0
2065 2065
      ],
2066 2066
      "settings": {
2067 2067
        "foreground": "#eba0ac"
2068 2068
      }
2069 2069
    },
2070 +
    {
2071 +
      "scope": "meta.function.definition.rust variable.parameter.rust",
2072 +
      "settings": {
2073 +
        "foreground": "#cdd6f4"
2074 +
      }
2075 +
    },
2070 2076
    {
2071 2077
      "scope": "meta.function.call.rust variable.other.rust",
2072 2078
      "settings": {
2073 2079
        "foreground": "#cdd6f4"
2074 2080
      }
crates/highlight/syntaxes/rust.json +4 -0
503 503
              "include": "#strings"
504 504
            },
505 505
            {
506 506
              "include": "#types"
507 507
            },
508 +
            {
509 +
              "match": "\\b(?:r#(?!(crate|[Ss]elf|super)))?[0-9_a-z]+\\b(?=\\s*:)",
510 +
              "name": "variable.parameter.rust"
511 +
            },
508 512
            {
509 513
              "include": "#variables"
510 514
            }
511 515
          ]
512 516
        },
crates/highlight/tests/syntaxes.rs +18 -0
137 137
        scopes.contains(&"comment.block.documentation.ts"),
138 138
        "{scopes:?}"
139 139
    );
140 140
}
141 141
142 +
#[test]
143 +
fn rust_highlights_function_signature_parameters() {
144 +
    let grammar = Grammar::from_str(syntaxes::RUST).unwrap();
145 +
    let mut state = LineState::default();
146 +
    let mut tokenizer = LineTokenizer::new(&grammar);
147 +
    let _ = tokenizer.tokenize_line(&mut state, "fn reconcile_with<C, E>(");
148 +
    let spans = tokenizer.tokenize_line(&mut state, "    mut cursor: String,");
149 +
    let scopes = spans
150 +
        .iter()
151 +
        .filter_map(|span| grammar.scopes.get(span.scope.index()))
152 +
        .map(String::as_str)
153 +
        .collect::<Vec<_>>();
154 +
155 +
    assert!(scopes.contains(&"storage.modifier.mut.rust"));
156 +
    assert!(scopes.contains(&"variable.parameter.rust"));
157 +
    assert!(scopes.contains(&"entity.name.type.rust"));
158 +
}
159 +
142 160
#[test]
143 161
fn fish_highlights_keywords_variables_and_strings() {
144 162
    let grammar = Grammar::from_str(syntaxes::FISH).unwrap();
145 163
    let scopes = tokenize_scopes(&grammar, "if test -n \"$argv\"");
146 164