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‐definition for packages, library functions and options #538

Open
2 of 5 tasks
emilazy opened this issue Jul 7, 2024 · 5 comments
Open
2 of 5 tasks

Jump‐to‐definition for packages, library functions and options #538

emilazy opened this issue Jul 7, 2024 · 5 comments
Labels
enhancement New feature or request

Comments

@emilazy
Copy link

emilazy commented Jul 7, 2024

Is your feature request related to a problem? Please describe.
Using Nix, especially working on Nixpkgs, involves an awful lot of grepping over the Nixpkgs code to find definitions. It would be great to have it in the editor instead.

Describe the solution you'd like
I think there are some pretty simple heuristics that would work for the majority of cases here:

This could also enable documentation‐on‐hover for these (nixdoc for library functions, description/longDescription/etc. for packages, and the native option documentation), which would be fantastic!

Describe alternatives you've considered
Continue getting really fast at using ripgrep :)

@inclyc inclyc added the enhancement New feature or request label Jul 8, 2024
@inclyc
Copy link
Member

inclyc commented Jul 8, 2024

Hi @emilazy ,

Thanks for suggestions on this project ❤️ .

Currently nixd-attrs-eval is used for evaluating "nixpkgs" attribute set. It is basically working except lib completion, and I think lib will not be very difficult.

pkgs.‹name› could be assumed to point to a Nixpkgs package definition if the package

Yes, supporting selection effectively resolves this.

This could also enable documentation‐on‐hover for these (nixdoc for library functions,

I see, it is generally ugly to have nixdoc as an external source for documentation. Why not just read that file again by ourselves? AFAIK nixdoc is based on rnix-parser and the parser is not really maintained.

the native option documentation)

What is the "native" option documentation?

Continue getting really fast at using ripgrep :)

No, that's not an alternative 😄 . This project exists, and aims to replace "grepping" technology used in nix community for years. Theoretically programming languages cannot be fully analyzed without "AST", not just DFAs (regexp).

@emilazy
Copy link
Author

emilazy commented Jul 8, 2024

I see, it is generally ugly to have nixdoc as an external source for documentation. Why not just read that file again by ourselves? AFAIK nixdoc is based on rnix-parser and the parser is not really maintained.

Ah, I just meant the RFC 145 comment syntax / CommonMark format / etc. used by nixdoc; I should probably have said that instead. That would be the standard for documenting “library values” (as opposed to options or packages).

What is the "native" option documentation?

The type/description/default{,Text}/example{,Text} option attributes, like the option documentation in the manual shows.

@inclyc
Copy link
Member

inclyc commented Jul 8, 2024

option attributes, like the option documentation in the manual shows.

I suppose this feature has already implemented in #526 ?

@emilazy
Copy link
Author

emilazy commented Jul 8, 2024

Ah, so it is! Maybe there’s some issue with my editor integration that made it seem not to work, or maybe it’s just because of the ambiguous option sets I have in my configuration. I’ll report an issue if I manage to reproduce it.

@573
Copy link
Collaborator

573 commented Sep 13, 2024

I can only visit builtins documentation via hover (K) so far, which is a cool feature but maybe could be expanded to blend in nixdoc strings in general.

Is there anything I might have missed configuring vim ? Mostly copied here
EDIT: Answering myself, it was crucial to add (nvim-treesitter.withPlugins (parsers: [ parsers.nix parsers.markdown_inline parsers.markdown ])) besides what is suggested here - flake-parts there is optional.

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