nix-community / nixd

Nix language server, based on nix libraries [maintainer=@inclyc,@Aleksanaa]
https://github.com/nix-community/nixd
GNU Lesser General Public License v3.0
891 stars 28 forks source link

nixpkgs completion and goto only work in lists #471

Closed ibrokemypie closed 3 months ago

ibrokemypie commented 6 months ago

If I write the following, nixd will autosuggest package names, include docs about them and allow me to jump to their definitions:

{pkgs}:
{
  asdf = with pkgs; [asdf];
}

However, if I write something like below, none of these features work anymore

{pkgs}:
{
  asdf = pkgs.asdf;
}

No idea why this is happening, it feels like a bug but it could be a misconfiguration, I do not know.

inclyc commented 6 months ago

https://github.com/nix-community/nixd/blob/b3515c91a56b9a1008a375116da46e9f8c8eb261/nixd/lib/Controller/AST.cpp#L104

This is not a bug nor misconfiguration, but an un-implemented feature.

For a long time C++ part in this project has only one developer, so there is no complex 'idiom' matching stuff implemented. Thus nixd currently only provides package information, by stupid with pkgs; arrays, it even not check whether pkgs is actually nixpkgs or not.

inclyc commented 6 months ago

Note: previously (version 1.x) nixd will perform precise eval, allowing end-users do any kind of 'goto-def', but requires some configuration stuff.

Then people complained:

"I don't want to configure nixd each project"

"other lsps work out of box!"

So let's do less configuration, but 'eval' will not be very precise. That's somehow a trade-off result.

inclyc commented 6 months ago

In conclusion I do think 'ExprSelect' like (pkgs.) should be implemented, but this is hard with incremental eval, and not yet landed.

inclyc commented 3 months ago

Fixed in #544