feat(code-action): add selection-based JSON to Nix conversion action#763
Merged
Conversation
- Introduce escapeNixString for proper Nix string escaping - Refactor quoteNixAttrKey to use escapeNixString - Add jsonToNix for converting JSON values to Nix syntax - Implement addJsonToNixAction to enable selection-based JSON-to-Nix code action - Integrate new action into onCodeAction for arbitrary text selections
- Add tests for arrays, nested objects, numeric edge cases, string escaping, interpolation, special keys, and all JSON types - Add negative tests for empty arrays/objects, invalid JSON, and exceeding depth/width limits - Ensure "Convert JSON to Nix" action is only offered for valid, convertible JSON selections
- Split overly long comments to improve readability - No functional changes to code logic
3 tasks
inclyc
approved these changes
Jan 8, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Add a new code action that converts selected JSON text to Nix expression syntax.
This is a selection-based action that works on arbitrary text within a Nix file, allowing users to quickly convert JSON data structures to their Nix equivalents.
Example:
{"foo": 1, "bar": true, "nested": {"key": "value"}} → { foo = 1; bar = true; nested = { key = "value"; }; }Changes
Behavior
Action offered when:
Explicitly excluded:
Safety limits:
Escape handling:
Test Plan
Related