Skip to content

Escaping DOLLAR_CURLY seems not to be recognized in indented strings #641

@jeslinmx

Description

@jeslinmx

Describe the bug
From this discussion, it is stated that ''\ escapes any other character in indented strings (but I can't find the original source for this). I can confirm it works:

image

As can be seen, ''\${1:-x} evaluates to ${1:-x}, so the bits within the curly braces are literal, rather than a nix string interpolation. This is useful for creating bash scripts.

However, nixd recognizes the part after the curly brace as an Identifier (as though it was part of a string interpolation), rather than an InterpolableParts (part of a string). It also throws up the following diagnostics:
image

Logs (Required)

Sorry, I'm not familiar with how to get logs out of neovim's lsp. I can append this on later if required.

Configuration

Nothing unusual:

    lspconfig.nixd.setup {
      settings = { nixd = {
        options = {
          -- nixos = { expr = "" },
          -- home_manager = { expr = "" },
        },
      }},
    }

To Reproduce
Steps to reproduce the behavior:

  1. Enter a multiline/indented string
  2. Escape a dollar sign before a curly open brace (i.e. ''\${)
  3. Enter something which would be invalid in a nix string interpolation

Expected behavior
nixd should ignore whatever follows the curly brace, as this is a literal ${ and not the beginning of a nix string interpolation.

Screenshots
If applicable, add screenshots to help explain your problem.

Additional context
Alejandra seems to have a similar problem.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workinglibnixf:parseThe nixf parser

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions