Skip to content

Conversation

@parkers0405
Copy link

@parkers0405 parkers0405 commented Jan 29, 2026

Summary

Adds Nix-specific treesitter node types for better chunk indicator support in Nix files.

Problem

Currently, hlchunk only shows chunk indicators for top-level scopes in Nix files. Nix has many nested scope types (let expressions, attribute sets, lambda functions, etc.) that weren't being detected.

Solution

Add nix.lua with Nix-specific treesitter node types as a table (not array):

  • let_expression - let ... in ... blocks
  • attrset_expression - { ... } attribute sets
  • rec_attrset_expression - rec { ... } recursive sets
  • list_expression - [ ... ] lists
  • lambda_expression - arg: body functions
  • function_expression - { args }: body functions
  • with_expression - with ...; ... expressions
  • if_expression - conditionals
  • assert_expression - assertions
  • binding - name = value; bindings

Benefits

Better visual feedback when editing Nix flakes and configurations. Users can now see chunk indicators for:

  • Input/output blocks in flakes
  • Each host configuration
  • Let bindings and their scopes
  • Nested attribute sets
  • Function definitions

Especially useful for NixOS configurations and flake structures.

Testing

Tested on NixOS with Nix flakes and configuration files. Chunk indicators now appear for all nested scopes.

Parker Settle added 2 commits January 28, 2026 21:20
- Add node_type field to Scope class to track treesitter node type
- Pass node_type from chunkHelper to render function
- Add node_type_styles config option for pattern-based style mapping
- Create dynamic highlight groups based on node type patterns
- Also includes virt_text_repeat_linebreak fix for wrapped lines

Example config:
  node_type_styles = {
    ["^func"] = { fg = "#99aee5" },  -- functions: blue
    ["^if"] = { fg = "#c2a2e3" },    -- conditionals: purple
    ["^for"] = { fg = "#fbdf90" },   -- loops: yellow
  }

This allows different colored chunk indicators for different scope types
(functions, loops, conditionals, etc.) when use_treesitter is enabled.
- Add nix.lua with Nix-specific treesitter node types
- Enables chunk indicators for let expressions, attrsets, lambdas, etc.
- Provides better visual feedback for Nix flake structure

This allows hlchunk to show arrows/indicators for all nested scopes
in Nix files (inputs, outputs, let blocks, attribute sets, etc.)
instead of just top-level scopes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant