Structural Editingλ︎
Structural editing ensures parenthesis (parens) and other pairs of characters remain balanced when entering or changing code, i.e. an open paren is not removed without removing the closing paren.
Parinfer and Paredit plugins provides a way to manage parens effectively
- nvim-parinfer manages the surrounding parens with indentation used for nested parens stuctures.
- nvim-treesitter-sexp paredit features, automatic balancing of parens and commands to refactor code structure
Practicalli recommends Parinfer & vim-style editing
AstroNvim Community Clojure Pack includes parinfer & paredit
nvim-parinfer plugin is included in the AstroNvim Community Clojure pack
Parinferλ︎
Parinfer provides an easy to use approach that works in concert with vim-style modal editing.
The author of the code focuses on aligning code and parinfer takes care of balancing the parens.
To include new lines of code within an expression, create a new line o
and indent.
Parinfer will move the preceeding closing paren(s) to the new line, enclosing the new code in the overall expression.
Pareditλ︎
nvim-treesitter-sexp will automatically manage open and close parens.
Paredit commands are provided to refactor lisp-style code and keep the parens balanced, e.g. slup, barf, promote (raise) expression, etc.
Example nvim-treesitter-sexp commands