Skip to content

[Feature Request] allow blank line as first line within functions #6854

@bogzbonny

Description

@bogzbonny

Feature Request

Summary

I love rust (and its formatting!). My single largest formatting pet peeve is the inability to have a blank line as the first line within a function contents. I often find this visually desirable to have that extra break when there are large function signatures with large comments.

More broadly this pattern seems to apply to most curly bracket situations (eg. if statements). Not allowing for this whitespace, to me, makes the code visually more cluttered/harder to read.

(Apologies if this is a dup issue, I couldn't find it directly in my review)

Example

Existing rustfmt only allows for:

/// Try to generate a suggestion using the data in the cache
/// Looks at the previous X characters to see if a completion is cached.
/// If one is found at (x,y) then it checks that the characters typed after (x,y)
/// match up with the cached completion result.
///
/// # Returns
///  - `Some(RenderedSuggestion)` - If a cached completion is found
///  - `None` - If no cached completion is found
pub fn fim_try_hint_inner(
    state: Arc<PluginState>,
    pos_x: usize,
    pos_y: usize,
    buffer_handle: u64,
    lines: Vec<String>,
) -> LttwResult<()> {
    // Get local context
    let ctx = get_local_context(&lines, pos_x, pos_y, None, &state.config.read());
    state.debug_manager.read().log("fim_try_hint_inner", "");

    // Compute primary hash
    let primary_hash = format!("{}{}{}{}", ctx.prefix, ctx.middle, "Î", ctx.suffix);
    let hash = sha256(&primary_hash);

...

Whereas it would be very nice to allow for:

/// Try to generate a suggestion using the data in the cache
/// Looks at the previous X characters to see if a completion is cached.
/// If one is found at (x,y) then it checks that the characters typed after (x,y)
/// match up with the cached completion result.
///
/// # Returns
///  - `Some(RenderedSuggestion)` - If a cached completion is found
///  - `None` - If no cached completion is found
pub fn fim_try_hint_inner(
    state: Arc<PluginState>,
    pos_x: usize,
    pos_y: usize,
    buffer_handle: u64,
    lines: Vec<String>,
) -> LttwResult<()> {

    // Get local context
    let ctx = get_local_context(&lines, pos_x, pos_y, None, &state.config.read());
    state.debug_manager.read().log("fim_try_hint_inner", "");

    // Compute primary hash
    let primary_hash = format!("{}{}{}{}", ctx.prefix, ctx.middle, "Î", ctx.suffix);
    let hash = sha256(&primary_hash);

...

Related configuration options

related #4930

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-whitespaceArea: whitespace and its handlingC-feature-requestCategory: a feature request (not decided/implemented)P-lowLow priority

    Type

    No type
    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