nix-community / nix-ts-mode

An Emacs major mode for editing Nix expressions, powered by tree-sitter [maintainer=@remi-gelinas]
https://github.com/nix-community/nix-ts-mode
Other
50 stars 9 forks source link

feat: #14 Improve multi-line string indentation #15

Closed antifuchs closed 4 months ago

antifuchs commented 8 months ago

Since treesit's "simple" indentation functions don't play too well with multi-line strings, create a new function, nix-ts-indent-multiline-string, which determines the point to which a line should be indented based on some simple heuristics: The first line in the multiline string gets indented to (offset+prev line); the following lines get their (manual) indentation left alone, and default to the offset of the previous line.

This fixes #14.

antifuchs commented 8 months ago

(I pushed two updates to this that should handle indenting ${} on a line and make first-line indent behavior more robust, too: I think this is basically "working" now, but I'd love to see if we can make a test for it)

Update: OK, now we've got tests - hope they actually run in a blank slate, as I can only run them interactively now (see #16)

purcell commented 4 months ago

This looks good, so I'll take the liberty of merging.