Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature Request: Only show indent lines on my current code "block" #561

Open
twiclo opened this issue Apr 18, 2023 · 9 comments
Open

Feature Request: Only show indent lines on my current code "block" #561

twiclo opened this issue Apr 18, 2023 · 9 comments
Labels
enhancement New feature or request

Comments

@twiclo
Copy link

twiclo commented Apr 18, 2023

Say I have this code block

impl Location {
│ pub async fn get_by_id(id: i32) -> Result<Self, Error> {
│ │ Ok(sqlx::query_as!(Self, r#"SELECT * FROM location WHERE location_id = $1"#, id).fetch_one(&ctx.pool).await?)
│ }
}

impl Address {
│ pub async fn get_by_id(id: i32) -> Result<Self, Error> {
│ │ Ok(sqlx::query_as!(Self, r#"SELECT * FROM location WHERE location_id = $1"#, id).fetch_one(&ctx.pool).await?)
│ }█
}

Notice the cursor is in the second code block. I would hope the guides would only show under the impl Address block:

impl Location {
  pub async fn get_by_id(id: i32) -> Result<Self, Error> {
    Ok(sqlx::query_as!(Self, r#"SELECT * FROM location WHERE location_id = $1"#, id).fetch_one(&ctx.pool).await?)
  }
}

impl Address {
│ pub async fn get_by_id(id: i32) -> Result<Self, Error> {
│ │ Ok(sqlx::query_as!(Self, r#"SELECT * FROM location WHERE location_id = $1"#, id).fetch_one(&ctx.pool).await?)
│ }█
}

I think it could look cleaner

@lukas-reineke
Copy link
Owner

I'm not against the idea, but this would actually be pretty difficult to add with the current implementation.

@windowsrefund
Copy link

Practically speaking, it seems like you are looking for twilight

@ndom91
Copy link

ndom91 commented Oct 2, 2023

Wasn't this possible in < v3 with the show_current_context = true option? I remember thats how mine used to work and I'm trying to get it to behave the same with v3 without any luck :/

@lukas-reineke
Copy link
Owner

No, this was never supported and still isn't.

@Danielkonge
Copy link
Contributor

Danielkonge commented Oct 9, 2023

I have a small addition to the code that does this now, but what behavior would you want when the cursor is between the two impl blocks? Should it show indents for both or no indents at all? (My current code shows no indentations when you are not inside any block, since this can then also be used to save some work.)

@twiclo
Copy link
Author

twiclo commented Oct 9, 2023

I think showing indents for everything is a fine idea. I would say make it a setting so users can choose. Thanks for doing the work on this

@Danielkonge
Copy link
Contributor

Ah, I just edited it to not show indents when not in a block now, since I thought that could save work too. But this could definitely be an option, though I worry adding extra options to what is already a sub-option could be confusing. I would probably want @lukas-reineke's input on how we would want this to be implemented before adding that kind of option.

If you want me to change anything (I have only briefly checked that it worked as I expected), you can try it from my latest commit here: #703

The option can be enabled by adding something like indent = { current_block_only = true } to your config when using that commit.

@lukas-reineke
Copy link
Owner

Your PR is already really big, let's focus on current indent first. I'm happy to add this as well, but let's make that a separate PR.
Then we can discuss there how it should work.

@Danielkonge
Copy link
Contributor

If you didn't see, I also asked in the PR if you prefer to have it split up. I will just split it into smaller parts tomorrow.

Danielkonge pushed a commit to Danielkonge/indent-blankline.nvim that referenced this issue Oct 10, 2023
@lukas-reineke lukas-reineke added the enhancement New feature or request label Oct 23, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants