Subject: Re: bug#77094: 31.0.50; yaml-ts-mode does not indent after yaml mapping keys

From: Randy Taylor <[email-masked]>
Date: Tue, 18 Mar 2025 17:27:30 +0000

On Tuesday, March 18th, 2025 at 03:40, the_wurfkreuz via "Bug reports for GNU Emacs, the Swiss army knife of text editors" <[email-masked]> wrote:
> If i have a yaml file with this content:
> ```
> apiVersion: v1
> kind: Service
> metadata:
> ```
> 
> And i try to create a new line executing the `newline` command from the end
> of the 'metadata:' line, the newly created line wont be indented:
> 
> ```
> apiVersion: v1
> kind: Service
> metadata:
> following_text
> ```
> 
> But in the yaml-mode and any other text editor i've tried, it always
> indents after mapping keys like this:
> 
> ```
> apiVersion: v1
> kind: Service
> metadata:
>   following_text
> ```
> 
> 
> Steps to reproduce:
> 1. emacs -Q
> 2. Interactively install the yaml treesitter grammar (i've compiled from this repo https://github.com/ikatyang/tree-sitter-yaml)
> 3. M-x yaml-ts-mode
> 4. Clean the scratch buffer and paste this:
> 
> apiVersion: v1
> kind: Service
> metadata:
> 
> 5. Move the cursor to the 'metadata:' line. Use `move-end-of-line` and
> `newline` commands.
> 
> The cursor isn't indented and placed at the very start of the next line.
> I expect it to be indented.
> 

Thanks for the report.

yaml-ts-mode currently doesn't supply any indentation rules.

I have been working on them on and off for a long time but could never
get them perfect due to how the grammar behaves in certain cases and
sort of lost motivation. But they say you shouldn't let perfect be the
enemy of good.

I will update and cleanup what I've been working on hopefully sometime
later this week/weekend and post it here, and will deal with whatever edge
cases as they come up.