Skip to content

fix(esupports.indent): keep indentation of verbatim blocks without an injected TS parser#1685

Merged
benlubas merged 3 commits intonvim-neorg:mainfrom
ALVAROPING1:fix-auto-indent
Apr 28, 2025
Merged

fix(esupports.indent): keep indentation of verbatim blocks without an injected TS parser#1685
benlubas merged 3 commits intonvim-neorg:mainfrom
ALVAROPING1:fix-auto-indent

Conversation

@ALVAROPING1
Copy link
Contributor

This fixes = messing with the indentation of verbatim blocks when no language is injected (either because a parser doesn't exist/isn't installed, or because no language was specified). Sometimes this is used for diagrams, which get messed up if all lines are aligned with the tag start. The current implementation doesn't handle code blocks with norg as language (which i can't see a good use case for) and thus those won't get auto indented either

out.mp4

@benlubas
Copy link
Contributor

You're amazing for this. Testing this PR made me realize that the visual promotion is broken

If you visually select the contents of this block and press >

@code
one
  - two
  - three
@end

You get this:

@code
  one
- two
- three
@end

The first line is indented, and all the rest are given 0 indent.

This feels related to this PR. I wonder if you have a guess as to why this happens and could maybe include the fix? Otherwise I will probably dig into the code a bit myself

@ALVAROPING1
Copy link
Contributor Author

You're amazing for this. Testing this PR made me realize that the visual promotion is broken

If you visually select the contents of this block and press >

@code
one
  - two
  - three
@end

You get this:

@code
  one
- two
- three
@end

The first line is indented, and all the rest are given 0 indent.

This feels related to this PR. I wonder if you have a guess as to why this happens and could maybe include the fix? Otherwise I will probably dig into the code a bit myself

i have found a couple different bugs involved in the behavior of </>, but i think i know how to fix it

… operation

`indent.reindent_range()` expects 0-based, exclusive line ranges, but the lines returned by
`nvim_buf_get_mark()` for the `<`/`>` marks are 1-based, inclusive line ranges
…g ignored

indent-expression might return -1 as the indentation of a line to indicate that
neovim should handle the indentation of the line. When manually setting the
indentation of a line with `buffer_set_line_indent` using the indentation
returned by indent-expression however, the -1 indentation caused the indentation
to be set to 0 instead of kept as is
@ALVAROPING1
Copy link
Contributor Author

should be fixed now. I also fixed range promotion/demotion not auto-indenting the first line in the range

@benlubas benlubas merged commit aa35325 into nvim-neorg:main Apr 28, 2025
2 of 6 checks passed
@github-project-automation github-project-automation bot moved this from added-updated-reopened to done in sorting neorg issue tracker Apr 28, 2025
@ALVAROPING1 ALVAROPING1 deleted the fix-auto-indent branch April 28, 2025 20:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants