nixd icon indicating copy to clipboard operation
nixd copied to clipboard

Display full completion list when inside attribute set

Open koffydrop opened this issue 9 months ago • 12 comments

Is your feature request related to a problem? Please describe.

In attribute sets, when triggering completion while writing dot-separated names, with the cursor directly after a dot, nixd lists all possible completion values, Eg. in configuration.nix:

programs.zsh./*cursor*/

The same does not happen when nesting them.

programs = {
  zsh = {
    /*cursor*/
  };
};

no completion items appear until something is typed.

programs = {
  zsh = {
    e/*cursor*/ # suggests enable, enableAutosuggestions etc
  };
};

Describe the solution you'd like

Triggering completion inside an attribute set within whitespace should give the same list as when writing the values with dots.

Describe alternatives you've considered

Not nesting attribute sets, which is less convenient for my preference.

Additional context Image Image Image

koffydrop avatar Feb 24 '25 21:02 koffydrop

In attribute sets, when triggering completion while writing dot-separated names, with the cursor directly after a dot, nixd lists all possible completion values, Eg. in configuration.nix:

programs.zsh./cursor/

Wow, I was under the impression nixd just isn't capable of this kind of completion in general!

I'll be watching this issue hoping to switch back from nil.

BWagener avatar Mar 21 '25 13:03 BWagener

this is pretty much a killer feature and what I think would attract much more attention. Oh and also it behaves the same way when using nvim-cmp as op seems to use helix

bolives-hax avatar Apr 07 '25 14:04 bolives-hax

I've just done some quick development, and the main issue now is:

programs = {
  zsh = {
    /* | */
#      ^ Assuming the cursor is here,
  };
};

the current AST cannot determine whether it is inside a "comment body", which causes nixd to attempt "completion" within comments, and that is undesirable.

inclyc avatar Apr 08 '25 04:04 inclyc

One could argue that if you were to open autocompletion in a comment body in this way, what you're saying is still the expected behavior.

In that case it would be great to have the same behavior for line comments.

BWagener avatar Apr 08 '25 04:04 BWagener

Hi, I have the same "issue" with vscode. I was wondering if there was a configuration, to allow that. Any discovery?

hackardoX avatar Jun 01 '25 22:06 hackardoX

I have a fix for this + couple other improvements here: https://github.com/oandrew/nixd/tree/completion-fixes

diff: https://github.com/nix-community/nixd/compare/main...oandrew:nixd:completion-fixes

  • show completions when no text under cursor
  • increase number of returned completions to 1000
  • remove prefix filtering to let vscode do fuzzy matching i.e. typing networking.net will also suggest useNetworkd.

Commit for this specific issue: https://github.com/nix-community/nixd/commit/6e3a54914459d0f7782a9244b6db5fcaab47c95e

quick video:

https://github.com/user-attachments/assets/8b3a61a6-b6c0-452c-8271-5ef2ae0df8d7

oandrew avatar Jun 18 '25 17:06 oandrew

@oandrew do you want to create a PR for this?

hackardoX avatar Jun 22 '25 20:06 hackardoX

Any updates on this? This would be an extremely appealing feature.

ntedvs avatar Jul 23 '25 20:07 ntedvs

Any updates on this? This would be an extremely appealing feature.

There's already an open PR: https://github.com/nix-community/nixd/pull/698

Brisingr05 avatar Jul 28 '25 11:07 Brisingr05

There's already an open PR: #698

I'm new to the open source world. When will the PR be merged?

ntedvs avatar Aug 02 '25 22:08 ntedvs

There's already an open PR: #698

I'm new to the open source world. When will the PR be merged?

The comments must be addressed first.

inclyc avatar Sep 04 '25 11:09 inclyc

Any updates on this? This would be an extremely appealing feature.

I agree it would allow me to use nixd to its full potential

bolives-hax avatar Oct 09 '25 05:10 bolives-hax