nushell-ts-mode
nushell-ts-mode copied to clipboard
Improve indent rules for list/record values
As of e07ecc5, indentation rules for list values don't work properly.
In the following code snippet, typing return with cursor at @ would start the next line at offset 0, instead of offset 2:
let numbers = [@]
I think this is due to the use of "val_list" as a type name. Using treesit-inspect-mode I can see that while the [ token is labeled "val_list", the actual parent of the largest node at the beginning of the line (i.e. the 1st argument of the matcher and anchor commands) is instead "list_body".
The same method applies to record values, using the "record_body" parent type. In the following snippet, typing return with the cursor at @ would indent by 2 spaces as of this commit.
let handle = spawn-daemon {
id: a123
addr: "127.0.0.1:9000"@
}