I also think this is the best long-term solution. As you say, this guarantees 100% consistency between LSP and actual evaluation. I think it might also result in the least maintenance effort.
To actually do this, it might make most sense for you to just create a fork of nix, implement the features you need, and them submit them as a PR to upstream.
Potentially, this could be a faster solution to quickly get the most functionality possible into the hands of users.
I can’t judge the amount of effort either solution requires, though.
How can we complete nixos options on /etc/nixos/configuration.nix and package names on environment.systemPackages of /etc/nixos/configuration.nix? And can we have document hover for nixos options and package description on /etc/nixos/configuration.nix? I always cost many time to switch between browser which open https://search.nixos.org/options and https://search.nixos.org/packages and vim which open /etc/nixos/configuration.nix. If there are a language server can complete and hover nixos options and package names, it will be nice.
The documentation + example are provided with the completion list. “Hover” documentation is working in progress.
package description
v1.1.0 release has support “goto definition” for packages. The description & version is somehow easy to implemented, how about submit a formal issue (for feature-request) on github?
However, in /etc/nixos/configuration.nix, press n will get some completions like nix, nixpkgs. press nix. will get not any completion. Does it need any configuration?
I have read and git clone the example code and try to edit. There are some comments in the example code like press . will complete XXX but they does not work for me. I don’t know what something I miss
<flakeref> and <name> are not literal, that’s supposed to be the specific nixosConfigurations attribute you want to evaluate. For a non-flake setup presumably you just point it at configuration.nix (some clarification @inclyc ?).
There are some other settings that look like they need to be set as well, the docs aren’t particularly clear on what is required for which use cases (and don’t cover use cases like multi-output flakes - though I suspect that’s just setting multiple installables).
I’ve yet to get a config working too, wasn’t trying too hard. Gave up for now when it started segfaulting and freezing my editor.
You are writing a lambda which has some formal args, and these formals are not required to be a package name for callPackage. Actually it can be anything. Can you try some completion task from the examples?
Join our matrix group so that you can get real-time technical support.
And looks like the server crashed for some reason. How about compiling the main brach from source?