- Topiary: tree-sitter based uniform formatter
- This repo contains:
- languages.ncl: configuration that enables nushell
- nushell.scm: tree-sitter query DSL that defines the behavior of formatter for nushell
- stand-alone tests written in nushell
- install topiary-cli (0.5.1 above)
- clone this repo to
$env.XDG_CONFIG_HOME/topiary
- set environment variables
$env.TOPIARY_CONFIG_FILE = ($env.XDG_CONFIG_HOME | path join topiary languages.ncl)
$env.TOPIARY_LANGUAGE_DIR = ($env.XDG_CONFIG_HOME | path join topiary languages)
- update
languages.ncl
if Nickel error detected:grammar.source.git
fits recent updates of topiary github while the latest release of topiary-cli still uses the other way.
< grammar = {
---
> grammar.source.git = {
topiary format script.nu
- neovim: format on save with conform.nvim:
-- lazy.nvim setup
{
"stevearc/conform.nvim",
dependencies = { "mason.nvim" },
event = "VeryLazy",
opts = {
formatters_by_ft = {
nu = { "topiary_nu" },
},
formatters = {
topiary_nu = {
command = "topiary",
args = { "format", "--language", "nu" },
},
},
},
},
Help to find format issues with following method (dry-run, detects parsing/idempotence/semantic breaking):
source utils.nu
test_format <root-path-of-your-nushell-scripts>