Rust-Atom language rust: Rust language support in Atom

Rust language support in Atom

Adds syntax highlighting and snippets to Rust files in Atom.

Install

Install the package language-rust in Atom (Preferences->Packages) or Atom's package manager from a shell:

$ apm install language-rust

Bugs

Grammar rules were written from scratch. They seem to work for most cases. However there are most certainly still a few cases that result in wrong syntax highlighting. Feel free to fix it and send a pull request, or open an issue to report it.

Links

  • Rust -- a safe, concurrent, practical language
  • Atom -- a hackable text editor for the 21st Century

Comments

  • Rust's syntax highlighting breaks after `r#impl`
    Rust's syntax highlighting breaks after `r#impl`

    Sep 19, 2019

    From @rustka in https://github.com/microsoft/vscode/issues/81085

    Rust's syntax highlighting breaks after using impl keyword as a raw identifier.


    • VSCode version: 1.38.1
    • OS version: Linux x64

    Steps to reproduce:

    1. Open the editor;
    2. Set language mode to Rust;
    3. Paste the following code:
    use r#impl;
    fn main() {}
    
    1. Comment the first line by prefixing it with //; 4.1. This failure could also be prevented by replacing r#impl with r#impl {}, but this is not the real solution for that case.
    2. The syntax highlighting works properly back again.

    P.S.: I did test it on Atom editor (v1.40.1) and it seemed to work correctly.

    Reply
  • Support attributes in function definitions (parameter attributes)
    Support attributes in function definitions (parameter attributes)

    Nov 14, 2019

    Now that Rust 1.39.0 supports attributes on parameters, the grammar should be updated to allow attributes when parsing function definitions.

    Example:

    #[attr(foo = "bar")]
    fn foo(#[attr(foo = "bar")] p: u32) {
        println!("hi");
    }
    

    Notice that "bar" is not highlighted as a string, which is an included pattern in the attribute grammar.

    Additionally, parsing breaks when the attribute string has characters that are interpreted as Rust tokens:

    #[attr(foo = "bar")]
    fn foo(#[attr(foo = "{")] p: u32) {
      println!("hi");
    }
    

    Note that here { is being matched as the opening bracket of the function, causing the closing " to be matched as the start of a string (the remainder of the function is considered to be in the string).

    Reply
  • Escape \b in keyword.other.fn.rust
    Escape \b in keyword.other.fn.rust

    Feb 15, 2020

    I'm trying to open this file and convert it to json, this seemed to be a bug (?)

    The cson parser I'm using converts that string to \x08fn\x08

    Reply
  • update reserved keywords
    update reserved keywords

    Mar 11, 2020

    Updates reserved keywords. Most are removals. For instance, proc was removed here

    List: https://doc.rust-lang.org/reference/keywords.html#reserved-keywords

    Proof: https://play.rust-lang.org/?version=stable&mode=debug&edition=2018&gist=16ceeadb190d1804eab3cf5e8439c1bc (keywords are outdated at the playground as well, but the point is it compiles)

    Reply
  • Rust syntax highlighting breaks with raw strings in attributes
    Rust syntax highlighting breaks with raw strings in attributes

    Apr 23, 2020

    From @ExoticMatter in https://github.com/microsoft/vscode/issues/95782

    VSCode Version: 1.44.2

    When raw string literals that use ##s appear in attributes in a Rust file, syntax highlighting breaks.

    Steps to Reproduce:

    1. Copy the following code into a Rust source file:
    #[cfg(feature = r#"""#)]
    const _: () = ();
    

    You will get something similar to the following:

    Screenshot_20200421_121815

    Does this issue occur when all extensions are disabled?: Yes

    Reply
  • Reference to char breaks highlighting
    Reference to char breaks highlighting

    May 14, 2020

    image

    It appears that the contents of the char literal are incorrectly interpreted as a lifetime specifier with a spurious single quote on the end rather than a reference to a char.

    Reply
  • Don't highlight arguments including `fn` in their name
    Don't highlight arguments including `fn` in their name

    Feb 18, 2017

    e.g. fn part of fn_foo in fn foobar<F: Fn()>(fn_foo: F) { was highlighted.

    Reply
  • loading any rust file freezes the atom v0.196
    loading any rust file freezes the atom v0.196

    May 5, 2015

                                                                                                                                                                                                            bug invalid 
    Reply
  • == does not always highlight correctly
    == does not always highlight correctly

    Jul 15, 2015

    Not sure what triggers it, but here is an example -

    screen shot 2015-07-15 at 5 13 59 pm bug 
    Reply
  • Support function calls with type arguments
    Support function calls with type arguments

    Feb 18, 2017

    Generic function calls written in function::<Type>() form are not tokenized as entity.name.function.rust. This PR adds support for them.

    Reply
  • made all rust operators tokenize as unit
    made all rust operators tokenize as unit

    Nov 23, 2015

    this allows fonts like Fira Code and Monoid to render all rust operators with a ligature.

    “=>” is an operator used in matching, so it makes sense to include it

    enhancement 
    Reply
  • Added impl capture.
    Added impl capture.

    Feb 17, 2017

    Hopefully able to fix issues on incorrect impl highlighting like #7 and maybe #86

    Reply