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

options suggestion is not working without indentation #277

Closed
hellodword opened this issue Dec 19, 2023 · 3 comments · Fixed by #415
Closed

options suggestion is not working without indentation #277

hellodword opened this issue Dec 19, 2023 · 3 comments · Fixed by #415
Labels
bug Something isn't working

Comments

@hellodword
Copy link
Contributor

flake.nix

{
  inputs = {
    nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
    # use this fork for git repository
    flake-compat = {
      url = "github:inclyc/flake-compat";
      flake = false;
    };
  };

  outputs = { nixpkgs, nixos-privates, ... }@inputs: {
    foo = nixpkgs.lib.mkIf true;
    #                  ^ goto definition works here (and more)!

    nixosConfigurations."vbox" = nixpkgs.lib.nixosSystem {
      system = "x86_64-linux";
      modules = [
        (
          { config, pkgs, inputs, ... }:

          {
            networking.hostName = "vbox";

            boot.kernelPackages = pkgs.linuxPackages_6_6;

            boot.loader = {
              systemd-boot.enable = true;
              efi.canTouchEfiVariables = true;
              grub = {
                efiSupport = true;
                device = "nodev";
              };
            };

            system.stateVersion = "23.11";
          }

        )
      ];
      specialArgs = {
        inherit inputs;
      };
    };
  };
}

.nixd.json

{
    "eval": {
        "target": {
            "args": [
                "-f",
                "default.nix"
            ],
            "installable": "nixosConfigurations.vbox.config"
        },
        "workers": 5
    },
    "formatting": {
        "command": "nixpkgs-fmt"
    },
    "options": {
        "enable": true,
        "target": {
            "args": [],
            "installable": ".#nixosConfigurations.vbox.options"
        }
    }
}

Working:

diff --git a/flake.nix b/flake.nix
index df1c401..5c98eb4 100644
--- a/flake.nix
+++ b/flake.nix
@@ -23,6 +23,7 @@
 
             boot.kernelPackages = pkgs.linuxPackages_6_6;
 
+            boot.
             boot.loader = {
               systemd-boot.enable = true;
               efi.canTouchEfiVariables = true;

Working:

diff --git a/flake.nix b/flake.nix
index df1c401..fa62553 100644
--- a/flake.nix
+++ b/flake.nix
@@ -23,6 +23,7 @@
 
             boot.kernelPackages = pkgs.linuxPackages_6_6;
 
+ boot.
             boot.loader = {
               systemd-boot.enable = true;
               efi.canTouchEfiVariables = true;

Not working:

diff --git a/flake.nix b/flake.nix
index df1c401..1d38554 100644
--- a/flake.nix
+++ b/flake.nix
@@ -23,6 +23,7 @@
 
             boot.kernelPackages = pkgs.linuxPackages_6_6;
 
+boot.
             boot.loader = {
               systemd-boot.enable = true;
               efi.canTouchEfiVariables = true;

Maybe related logs:

I[06:36:25.405] 70527: --> notify nixd/ipc/eval
I[06:36:25.416] 70527: <-- textDocument/completion(409)
I[06:36:25.416] 70527: --> call nixd/ipc/textDocument/completion/options(764)
I[06:36:25.416] 70546: <-- nixd/ipc/textDocument/completion/options(764)
I[06:36:25.416] 70546: --> reply:nixd/ipc/textDocument/completion/options(764) �[31;1merror:�[0m attribute '�[35;1mpkgs�[0m' in selection path '�[35;1mpkgs.linuxPackages_6_6;

       boot.�[0m' not found, error: 3
I[06:36:25.417] 70527: <-- reply(764)
I[06:36:25.417] 70527: --> reply:textDocument/completion(409)
I[06:36:25.428] 150264: nixd nightly started
@inclyc
Copy link
Member

inclyc commented Dec 19, 2023

I think this is caused by we do not handle attrpath in ASTs, but playing with random strings checking \n, this is just a workaround for poor parser.

https://github.com/nix-community/nixd/blob/2611b45cf786e7ba1679cd4adfe256ca85b371f5/nixd/lib/Server/Controller.cpp#L605C9-L617C10

Currently the frontend (parser) does not support attrpath at all. We recently merged libnixf as the new parser, but it is currently not working with the Controller. The controller utilizes a parser cherry-picked from NixOS/nix repo, which does not allow us find attrpaths correctly.

Contributions are welcomed if you would like to do such thing, or just offload some of my work.

@inclyc
Copy link
Member

inclyc commented Dec 23, 2023

This should be addressed by the new frontend https://github.com/nix-community/nixd/tree/main/libnixf the merging work is still on-going. We currently blocked by in-complete semantic analysis module, and serialization algorithms.

@inclyc inclyc added the bug Something isn't working label Dec 24, 2023
@inclyc inclyc linked a pull request Apr 15, 2024 that will close this issue
@inclyc
Copy link
Member

inclyc commented Apr 16, 2024

In #415 attrpath is retrieved from AST. So this should be fixed.

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

Successfully merging a pull request may close this issue.

2 participants