nixd icon indicating copy to clipboard operation
nixd copied to clipboard

Value doc

Open inclyc opened this issue 1 year ago • 4 comments

This PR introduces nix-repl's :doc command to nixd.

Since https://github.com/NixOS/nix/pull/11072, we can utilize the API exposed by nix::EvalState::getDoc. (i.e. to provide hover/completions(todo) from nixpkgs's doc comments).

Current status:

  • [x] support hovering
  • [ ] support completion-list resolve
The :doc command in nix-repl Hovering on that value

Also CC @roberth (author of nix implementation), @hsjobeki (author of doc-comments RFC). How can we co-operate to make these stuff more fancy? (It looks very ugly so far, :laughing: )

I see there are some information for "definition" here, generally this information is separated from "hover-ed documentation" in LSP, can we have a new API to get a structured output?

inclyc avatar Nov 23 '24 17:11 inclyc

I am also in favor or just returning the content without Rendering it. Maybe as a function on the C-abi. But it should Return a struct with content, Position, and probably more metadata. Rendering is best done using the markdown Extensions from the documentation readme in nixpkgs.

hsjobeki avatar Nov 23 '24 18:11 hsjobeki

kindly ping @roberth, can we have a structured helper function exposed from nix-expr?

inclyc avatar Dec 12 '24 01:12 inclyc

Hey @inclyc, sorry for the delay. Happy to help if I can, but it's not quite clear to me what needs to be done in nix-expr. Currently the inside of the comment is not parsed, except with a markdown parser, of which I'm not even sure that it's the right parser, considering the mismatch with some extended syntax that's used in Nixpkgs. If, on the other hand, you're looking for some improvements in the interface around the already implemented functionality, we might have some low hanging fruit to pick there.

roberth avatar Feb 18 '25 15:02 roberth

This pull request has been mentioned on NixOS Discourse. There might be relevant details there:

https://discourse.nixos.org/t/why-nix-will-win-and-whats-stopping-it-a-3-year-production-story/70621/42

nixos-discourse avatar Oct 14 '25 08:10 nixos-discourse