Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Autocompletion does not work on the first line a configuration object #539

Open
Niikolajj opened this issue Jul 9, 2024 · 1 comment
Open
Labels
bug Something isn't working

Comments

@Niikolajj
Copy link

Niikolajj commented Jul 9, 2024

Describe the bug
Opening an object doesn't offer nixd autocompletions in the first line of the object

Logs (Required)

I[13:40:09.508] 8062: <-- textDocument/didChange
I[13:40:09.508] 8062: --> notify textDocument/publishDiagnostics
I[13:40:09.526] 8062: <-- textDocument/completion(1142)
I[13:40:09.526] 8062: --> reply:textDocument/completion(1142)
I[13:40:09.769] 8062: <-- textDocument/codeAction(1143)
I[13:40:09.769] 8062: --> reply:textDocument/codeAction(1143)
I[13:40:09.808] 8062: <-- textDocument/semanticTokens/full(1144)
I[13:40:09.808] 8062: --> reply:textDocument/semanticTokens/full(1144)
I[13:40:09.859] 8062: <-- textDocument/documentSymbol(1145)
I[13:40:09.859] 8062: <-- textDocument/documentSymbol(1146)
I[13:40:09.860] 8062: --> reply:textDocument/documentSymbol(1145)
I[13:40:09.860] 8062: --> reply:textDocument/documentSymbol(1146)
I[13:40:10.509] 8062: <-- textDocument/documentLink(1147)
I[13:40:10.509] 8062: --> reply:textDocument/documentLink(1147)
I[13:40:10.759] 8062: <-- textDocument/inlayHint(1148)
I[13:40:10.759] 8062: --> call attrset/attrpathInfo(1403)
I[13:40:10.759] 8062: <-- reply(1403)
I[13:40:10.759] 8062: --> call attrset/attrpathInfo(1404)
I[13:40:10.759] 8062: <-- reply(1404)
I[13:40:10.759] 8062: --> call attrset/attrpathInfo(1405)
I[13:40:10.760] 8062: <-- reply(1405)
I[13:40:10.760] 8062: --> call attrset/attrpathInfo(1406)
I[13:40:10.760] 8062: <-- reply(1406)
I[13:40:10.760] 8062: --> call attrset/attrpathInfo(1407)
I[13:40:10.760] 8062: <-- reply(1407)
I[13:40:10.760] 8062: --> call attrset/attrpathInfo(1408)
I[13:40:10.760] 8062: <-- reply(1408)
I[13:40:10.760] 8062: --> call attrset/attrpathInfo(1409)
I[13:40:10.761] 8062: <-- reply(1409)
I[13:40:10.761] 8062: --> call attrset/attrpathInfo(1410)
I[13:40:10.761] 8062: <-- reply(1410)
I[13:40:10.761] 8062: --> call attrset/attrpathInfo(1411)
I[13:40:10.761] 8062: <-- reply(1411)
I[13:40:10.761] 8062: --> call attrset/attrpathInfo(1412)
I[13:40:10.761] 8062: <-- reply(1412)
I[13:40:10.761] 8062: --> call attrset/attrpathInfo(1413)
I[13:40:10.761] 8062: <-- reply(1413)
I[13:40:10.761] 8062: --> call attrset/attrpathInfo(1414)
I[13:40:10.762] 8062: <-- reply(1414)
I[13:40:10.762] 8062: --> call attrset/attrpathInfo(1415)
I[13:40:10.762] 8062: <-- reply(1415)
I[13:40:10.762] 8062: --> reply:textDocument/inlayHint(1148)

Configuration

"nix.serverPath": "nixd",
"nix.serverSettings": {
        // settings for 'nixd' LSP
        "nixd": {
            "formatting": {
                // This is the default if ommited.
                "command": [ "nixfmt" ]
            },
            "options": {
                // By default, this entriy will be read from `import <nixpkgs> { }`
                // You can write arbitary nix expression here, to produce valid "options" declaration result.
                // Tip: for flake-based configuration, utilize `builtins.getFlake`
                "nixos": {
                    "expr": "(builtins.getFlake \"/etc/nixos\").nixosConfigurations.nixos.options"
                },
                "home-manager": {
                    "expr": "(builtins.getFlake \"/etc/nixos\").homeConfigurations.\"niko\".options"
                }
            }
        }
  }

To Reproduce
Steps to reproduce the behavior:

  1. type programs.foot = { };
  2. type e in the brackets
  3. generic intellisense autocompletes are coming up instead for "enable"

Expected behavior
It should show options available for the program, like it would when typing programs.foot.e

Additional context

  • nixd 2.2.2
  • vscode 1.9.1
  • nix ide v0.3.1
@Niikolajj Niikolajj added the bug Something isn't working label Jul 9, 2024
@inclyc
Copy link
Member

inclyc commented Jul 15, 2024

That is because when you type { somename| , the construct is guessed as a part of lambda functions, while the completion lists provided by nixd are context-aware (i.e. iff the cursor is in an attribute set).

Completions are expected to work with the following snippet, though:

{
  foo = 1;
  ba|
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants