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

Jump to declaration for nixos module config attributes #599

Open
Atemu opened this issue Sep 24, 2024 · 3 comments
Open

Jump to declaration for nixos module config attributes #599

Atemu opened this issue Sep 24, 2024 · 3 comments
Labels
enhancement New feature or request

Comments

@Atemu
Copy link

Atemu commented Sep 24, 2024

Is your feature request related to a problem? Please describe.
A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]

nixd is able to jump to NixOS option declarations from the point they're set but not the points where their value is read using the config argument.

Describe the solution you'd like
A clear and concise description of what you want to happen.

It'd be great if nixd could also jump to option declarations from config.option.name.here

Describe alternatives you've considered
A clear and concise description of any alternative solutions or features you've considered.

-

Additional context
Add any other context or screenshots about the feature request here.

It's common for config attributes to be put into another variable via let:

{ config, ... }:

let
  cfg = config.foo.bar;
in
{
  bar.foo = cfg.baz;
}

nixd should be able to resolve this redirection and jump to the declaration of options.foo.bar.baz when attempting to jump to the declaration of cfg.baz.

@inclyc
Copy link
Member

inclyc commented Sep 25, 2024

Generally I don't like to add more heuristics. I'd expect a mathmatical deducing model to address all these stuff.

Much similar problem also reported in #600, where we cannot deal with nixos options declared inside config.

I think finally a type system should be added in Nix language, we can do this in lsp first (like python's type annotation).

@luochen1990 do you have some ideas?

@luochen1990
Copy link

A type system in lsp is cool, but there is indeed two different mechanism we need to have if we choose to implement all these in lsp instead of a new language -- the type system for nixos modules, and the type system for normal nix codes. They are very different but intuitively can be fused into a single one, but I don't know how to fuse them yet

@Atemu
Copy link
Author

Atemu commented Sep 26, 2024

I don't think proper typing is going to happen in Nix any time soon. If work were to start now, I'd expect it to be usable no sooner than a decade later.

I also don't understand how a type system would be relevant here as this should be able to use a similar code-path to the current jump to option declaration; regardless of its type.

@inclyc inclyc added the enhancement New feature or request label Oct 9, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants