Skip to content

feat(code-action): add inherit to explicit binding conversion action#773

Merged
inclyc merged 1 commit into
mainfrom
feature/add-code-action-9
Jan 13, 2026
Merged

feat(code-action): add inherit to explicit binding conversion action#773
inclyc merged 1 commit into
mainfrom
feature/add-code-action-9

Conversation

@takeokunn

@takeokunn takeokunn commented Jan 13, 2026

Copy link
Copy Markdown
Collaborator

Summary

This PR adds a new "Convert to explicit binding" code action that converts inherit statements to explicit bindings:

  • Simple inherit: { inherit x; }{ x = x; }
  • Inherit from expression: { inherit (b) a; }{ a = b.a; }
Before After
{ inherit x; } { x = x; }
{ inherit (b) a; } { a = b.a; }
{ inherit (foo.bar) baz; } { baz = foo.bar.baz; }

Changes

File Description
nixd/lib/Controller/CodeActions/InheritToBinding.h Public interface declaration
nixd/lib/Controller/CodeActions/InheritToBinding.cpp Core implementation
nixd/lib/Controller/CodeAction.cpp Integration with dispatcher
nixd/lib/meson.build Build system integration

Behavior

The action is offered when:

  • Cursor is on an inherit statement
  • The inherit has exactly one name (single-name only)

Limitations:

  • Multi-name inherits (inherit x y z;) not supported
  • Only static (non-interpolated) attribute names handled

Test Plan

  • CI passes
    • 5 regression tests:
      • basic.md: Simple inherit (inherit xx = x)
      • with-expr.md: Inherit from variable (inherit (b) aa = b.a)
      • complex-expr.md: Nested expression (inherit (foo.bar) baz)
      • long-name.md: Long attribute names
      • multi-name-negative.md: Multi-name inherits do NOT offer action

Related

…me inherits

- Introduce addInheritToBindingAction to convert single-name inherit
  statements to explicit bindings
- Support both simple and expression-based inherits, e.g.:
  - { inherit x; } -> { x = x; }
  - { inherit (b) a; } -> { a = b.a; }
- Only offer the action when the inherit statement has exactly one name
- Add tests for basic, complex, long-name, and negative multi-name cases
- Register new code action in build system and controller
@takeokunn takeokunn added enhancement New feature or request nixd:controller labels Jan 13, 2026
@takeokunn takeokunn marked this pull request as ready for review January 13, 2026 13:44
@takeokunn takeokunn requested a review from inclyc as a code owner January 13, 2026 13:44
@inclyc inclyc merged commit 0c919af into main Jan 13, 2026
19 checks passed
@inclyc inclyc deleted the feature/add-code-action-9 branch January 13, 2026 15:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request nixd:controller

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants