diff --git a/dumb-jump.el b/dumb-jump.el index 6ca1695..169ce19 100644 --- a/dumb-jump.el +++ b/dumb-jump.el @@ -339,12 +339,15 @@ ;; rust (:type "variable" :supports ("ag" "grep") :language "rust" - :regex "\\blet\\s+(mut\\s+)?JJJ(:\\s*[^=\\n]+)?\\s*=\\s*[^=\\n]+" + :regex "\\blet\\s+(\\\([^=\\n]*)?(mut\s+)?JJJ([^=\\n]*\\\))?(:\\s*[^=\\n]+)?\\s*=\\s*[^=\\n]+" :tests ("let test = 1234;" "let test: u32 = 1234;" "let test: Vec = Vec::new();" "let mut test = 1234;" - "let mut test: Vec = Vec::new();")) + "let mut test: Vec = Vec::new();" + "let (a, test, b) = (1, 2, 3);" + "let (a, mut test, mut b) = (1, 2, 3);" + "let (mut a, mut test): (u32, usize) = (1, 2);")) (:type "variable" :supports ("ag" "grep") :language "rust" :regex "\\bconst\\s+JJJ:\\s*[^=\\n]+\\s*=[^=\\n]+" @@ -359,25 +362,34 @@ (:type "variable" :supports ("ag" "grep") :language "rust" :regex "\\bfn\\s+.+\\s*\\\((.+,\\s+)?JJJ:\\s*[^=\\n]+\\s*(,\\s*.+)*\\\)" :tests ("fn abc(test: u32) -> u32 {" - "fn abc(x: u32, y: u32, test: Vec, z: Vec)")) + "fn abc(x: u32, y: u32, test: Vec, z: Vec)" + "fn abc(x: u32, y: u32, test: &mut Vec, z: Vec)")) ;; "if let" and "while let" desugaring (:type "variable" :supports ("ag" "grep") :language "rust" - :regex "(if|while)\\s+let\\s+\\w+\\\((mut\\s+)?JJJ\\\)\\s*=\\s*[^=\\n]+\\s*{" + :regex "(if|while)\\s+let\\s+([^=\\n]+)?(mut\\s+)?JJJ([^=\\n\\\(]+)?\\s*=\\s*[^=\\n]+" :tests ("if let Some(test) = abc() {" "if let Some(mut test) = abc() {" "if let Ok(test) = abc() {" "if let Ok(mut test) = abc() {" + "if let Foo(mut test) = foo {" + "if let test = abc() {" + "if let Some(test) = abc()" + "if let Some((a, test, b)) = abc()" "while let Some(test) = abc() {" "while let Some(mut test) = abc() {" "while let Ok(test) = abc() {" - "while let Ok(mut test) = abc() {" - "while let Foo(mut test) = foo {")) + "while let Ok(mut test) = abc() {") + :not ("while let test(foo) = abc() {")) (:type "function" :supports ("ag" "grep") :language "rust" :regex "\\bfn\\s+JJJ\\s*\\\(" :tests ("fn test(asdf: u32)" "fn test()" "pub fn test()")) + (:type "function" :supports ("ag" "grep") :language "rust" + :regex "\\bmacro_rules!\\s+JJJ" + :tests ("macro_rules! test")) + (:type "type" :supports ("ag" "grep") :language "rust" :regex "struct\\s+JJJ\\s*[{\\\(]?" :tests ("struct test(u32, u32)" @@ -398,7 +410,11 @@ :tests ("impl test {" "impl abc::test {" "impl std::io::Read for test {" - "impl std::io::Read for abc::test {"))) + "impl std::io::Read for abc::test {")) + + (:type "type" :supports ("ag" "grep") :language "rust" + :regex "mod\\s+JJJ\\s*{?" + :tests ("mod test;" "pub mod test {"))) "List of regex patttern templates organized by language and type to use for generating the grep command"