nix-mode icon indicating copy to clipboard operation
nix-mode copied to clipboard

`${` inside a string breaks the string

Open terlar opened this issue 5 years ago • 4 comments

{
  test = "hello ${interpolated} world";
}

Running the command (nth 3 (syntax-ppss)) up until the $ will return true indicating this is within a string, but when you hit the { it will return nil until one character after the end }.

"~hello $~{interpolated} ~world~"

The strike-through parts are the ones regarded as string.

This breaks tools operating on strings.

I noticed this as part of: https://github.com/twlz0ne/separedit.el/issues/9

terlar avatar Mar 23 '20 07:03 terlar

So I'm not sure if there's a good solution. $ probably shouldn't be part of the string while the trailing should be.

But we want the stuff in the ${} to be handled like any other Nix code, not treated like a string. You can use the nix-string-type to get a little better view of where the string starts and ends, but it's not

matthewbauer avatar May 10 '20 02:05 matthewbauer

Unfortunately, existing behavior makes using " text object in evil-mode unusable in nix files with string interpolation`.

wedens avatar Jun 01 '20 07:06 wedens

This is still an issue unfortunately.

Common operations like trying to clear the contents of a string via e.g. c i " are completely unreliable in nix-mode because the inner dection after a string with antiquotation is completely broken.

Atemu avatar Oct 16 '22 16:10 Atemu

FWIW, python-mode keeps the string syntax property for f-strings, and just propertises the expression within curly braces. Perhaps this is what we should do as well.

slotThe avatar Jan 09 '24 15:01 slotThe