A Neovim plugin for splitting and joining code blocks like arrays, objects, and statements using Tree-Sitter.
TreeSJ is a Neovim plugin that splits or joins code blocks—like arrays, objects, and statements—using Tree-Sitter for syntax-aware formatting. It solves the tedious task of manually reformatting code structures by toggling between single-line and multi-line representations with a single command.
Neovim users who frequently edit structured code in languages like JavaScript, TypeScript, Lua, Python, and others, and want faster, more precise block formatting.
Developers choose TreeSJ for its deep Tree-Sitter integration, which ensures accurate language detection and handling of complex nested structures, along with features like cursor stickiness and dot-repeat support that streamline editing workflows.
Neovim plugin for splitting/joining blocks of code
Open-Awesome is built by the community, for the community. Submit a project, suggest an awesome list, or help improve the catalog on GitHub.
Automatically detects whether to split or join based on block structure, eliminating the need for manual mode selection, as highlighted in the features.
Keeps the cursor on the text it was called from, ensuring workflow continuity, which is a core feature mentioned in the README.
Uses Tree-Sitter to recognize syntax across over 30 languages, from JavaScript to Zig, making it versatile for multi-language projects.
Can expand or collapse all nested nodes in a single action, saving time on deeply structured code, as demonstrated in the configuration examples.
Supports repeating the last action with the '.' command, enhancing editing efficiency, which is a listed feature.
Setting up custom nodes or languages requires deep understanding of Tree-Sitter AST and extensive Lua code, as shown in the advanced configuration section with functions like format_tree.
The plugin's functionality hinges on accurate Tree-Sitter parsing; any parser bugs or unsupported languages can lead to unreliable formatting, a risk admitted in the fallback options.
For non-standard code structures, users must implement custom fallback functions or presets, adding development time, as noted in examples like the Ruby conditional node.
Being a Neovim plugin, it offers no support for other editors or IDEs, limiting its adoption in mixed toolchain environments.
treesj is an open-source alternative to the following products: