Skip to content

A module to work with hierarchical text structure #2394

Description

@echasnovski

Contributing guidelines

Module(s)

new

Description

The suggested name is 'mini.hierarchy'. In particular:

  • Automatically compute hierarchy of the buffer text based on configurable sources (like "treesitter", "lsp", "indent"). It should be done only when needed, in debounced fashion, and ideally with as little computation as possible. Overall similar to 'mini.diff'.

    The hierarchical structure is a tree-like array of table nodes each containing information about its range, type and/or name, and a recursive array of children nodes (should have ranges inside the parent range). Sibling ranges should intersect, but their union is allowed to not cover the whole parent range (i.e. there can be "empty" spots).

  • Provide functionality that leverages the text hierarchy. Like:

    • Incremental selection in Visual mode: select parent/child/next-sibling/prev-sibling. Probably behind default si / sI / sn / sN mappings.
    • Navigate to start of parent/child/next-sibling/prev-sibling. Probably behind default [{ / ]} / ]] / [[. Not sure how to navigate to their end, as navigate to start/end of the node based only on cursor is not really useful as it will use the smallest node.
    • Possibly textobjects for 'mini.ai'.
    • Compute "current hierarchy branch" to be displayed as the typical "breadcrumbs" in winbar. See mini.breadcrumbs plugin to show breadcrumbs of current cursor position using treesitter. #983.
    • Automatically dim parts of text that are not in the "current hierarchy branch". See Dim inactive portions of the code you're editing #2392.
    • Toggle-able overview of the whole tree structure.
    • Fold method that folds based on the nesting level of the "hierarchy node at cursor".

Metadata

Metadata

Assignees

No one assigned

    Labels

    new-moduleRequest for the new module

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions