feat(parsing): add Nix language parser#106
Open
antono wants to merge 4 commits into
Open
Conversation
Execution plan for adding Nix language support to codanna under the per-parser docs convention (contributing/parsers/nix/). - Compatibility verdict for tree-sitter-nix 0.3.0 (LanguageFn / ABI-15, compatible with tree-sitter 0.26) - Module + wiring map, trait architecture, and Nix->symbol mapping - Parser traversal and scope-resolution logic - 6-phase execution plan with touch-point checklist - 5 Mermaid diagrams (GitHub-render-safe, quoted labels)
- tree-sitter-nix 0.3.0 via nix-community (ABI-15) - Parses attrsets, rec attrsets, let expressions, lambdas (universal + formals), inherit / inherit_from, apply_expression, select_expression - 100% key-node coverage (18/18) in audit - Language::Nix wired into registry, factory, language.rs, io/parse.rs - default_enabled = false (flip to true at release) - flake.lock → rustc 1.95.0 (required by sysinfo 0.39.2) - 40 new tests across unit, integration, and abi15 audit
Contributor
|
❌ Quick checks failure |
Fix cargo fmt check failures on CI.
Prior commit used standalone rustfmt which sorts imports differently from cargo fmt run inside the nix devshell. Use nix develop going forward to match CI exactly.
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.
Purpose
Adds full Nix expression-language support to codanna, enabling symbol extraction, call tracking, import resolution, and scope-aware lookup for
.nixfiles (NixOS configs, Home Manager modules, flakes, packages, overlays).Implementation
Built on
tree-sitter-nix 0.3.0(nix-community, ABI-14/15), wired identically to the existing Lua parser (no trait overhead, attrset-centric scoping).New files —
src/parsing/nix/definition.rsNixLanguage—LanguageDefinitiontrait, registers the grammarparser.rsNixParser— symbol extraction, call tracking, import resolutionbehavior.rsNixBehavior—LanguageBehaviortrait, scope factoryresolution.rsNixResolutionContext— lexical + attrset scope chainaudit.rsmod.rsregister_nix_language()Symbols extracted
let-binding identifiers@-pattern with default)inheritnamesrec-attrset bindingsEdited — existing files
Cargo.toml,parsing/mod.rs,parsing/registry.rs,parsing/language.rs,tests/parsers_tests.rs,contributing/parsers/grammar-versions.lockTests
tests/parsers/nix/test_symbol_extraction.rs— 10 cases covering let bindings, attrsets, functions, inherit, rectests/parsers/nix/test_call_tracking.rs— 8 cases covering direct calls, lib references,pkgs.*,importtests/exploration/abi15_grammar_audit/nix.rs— ABI-15 coverage completenesstests/fixtures/nix/{basic,functions,imports}.nixexamples/nix/{main,comprehensive}.nixImplementation plan
Full design doc with trait architecture, module wiring, node mapping, and grammar audit:
contributing/parsers/nix/IMPLEMENTATION_PLAN.mdSupporting docs:
GRAMMAR_ANALYSIS.md— tree-sitter-nix node-type surveyNODE_MAPPING.md— Nix AST → codanna symbol/call mappingAUDIT_REPORT.md— ABI-15 coverage report