rust-lang / rust-mode

Emacs configuration for Rust
Apache License 2.0
1.13k stars 180 forks source link

Indentation issue after macro #167

Open lancecarlson opened 8 years ago

lancecarlson commented 8 years ago

I'm playing around with nickel and was trying to do some simple example apps. I had an indentation issue after the middleware! macro. See comment below:

#[macro_use] extern crate nickel;

use std::collections::HashMap;
use nickel::{Nickel, HttpRouter, StaticFilesHandler};

fn main() {
    let mut server = Nickel::new();

    server.utilize(StaticFilesHandler::new("public/"));

    server.get("/", middleware! { |_req, res|
        // When I press enter here, my cursor ends up right under req
        let mut data = HashMap::new();
        data.insert("name", "user");
        return res.render("views/index.html", &data)
    });

    server.listen("127.0.0.1:6767");
}
porglezomp commented 7 years ago

I've had a lot of trouble with getting indentation to behave inside macros, I'd really like a setting that makes being inside a macro disable visual indentation.

Occhioverde commented 1 year ago

Same problem here with Yew's html! macro. As you can see if you try to indent the following code, the formatter tries to move the pseudo-HTML lines, messing them up even if correctly indented via a manual intervention:

use yew::prelude::*;

#[function_component]
fn App() -> Html {
  html! {
      <div>
          <h1>{"Test code"}</h1>
          <div>
              <p>{"This is a test code to show the issue with indentation"}</p>
          </div>
      </div>
  }
}

fn main() {
  yew::Renderer::<App>::new().render();
}

It would be very nice to see a behaviour similar to rustfmt, which completely ignores code inside procedural macros.