nimpretty_t

Nim formatter that utilizes `nimpretty` while allowing for tab indentation and diff viewing.

Stale Pure Nim score 24/100 · last commit 2024-10-01 · 5 stars · tests present · no docs generated

Summary

Latest Version Unknown
License MIT
CI Status Failing
Stars 5
Forks 0
Open Issues 0
Last Commit 2024-10-01
Downloads 0
Last Indexed 2026-07-21 05:25

Installation

nimble install nimpretty_t
choosenim install nimpretty_t
git clone https://github.com/ttytm/nimpretty_t

OS Compatibility

Platform Linux macOS Windows FreeBSD OpenBSD NetBSD Android iOS WASM Embedded
nimpretty_t - - - - - - -

Source

Repository https://github.com/ttytm/nimpretty_t
Homepage https://github.com/ttytm/nimpretty_t
Registry Source github

README

nimpretty_t

Uses nimpretty to format Nim code while allowing for tab indentation and diff viewing.

Quick start

Overview

Usage

Usage: nimpretty_t [options] <path>...

Formatter and diff viewer utilizing nimpretty.
By default, formatted output is written to stdout.

Options:
  -w  --write           Modifies non-conforming files in-place.
  -l  --list            Prints paths of non-conforming files. Exits with an error if any are found.
  -d  --diff            Prints differences of non-conforming files. Exits with an error if any are found.
  -i  --indentation     Sets the indentation used [possible values: 'tabs', 'smart', '<num>'(spaces)].
                        - tabs: used by default.
                        - smart: based on the initial indentations in a file.
                        - <num>: number of spaces.
  -L  --line-length     Sets the max character line length. Default is 100.
      --stdin           Formats input from stdin.
  -h  --help            Prints this help information.
  -v  --version         Prints version information.

Environment Variables:
  NIM_DIFF_CMD          Sets a custom diff command that is used with the '-diff' option
                        E.g.: 'NIM_DIFFCMD="diff --color=always -U 2"'

Getting Started

Installation

  • Via nimble

sh nimble install nimpretty_t

Editor Setup

  • Neovim

Register nimpretty_t in null-ls/none-ls

lua local null_ls = require("null-ls") -- ... null_ls.register({ name = "nimpretty_t", method = null_ls.methods.FORMATTING, filetypes = { "nim" }, generator = null_ls.formatter({ command = "nimpretty_t", args = { "-w", "$FILENAME" }, to_temp_file = true, }), })

A complementary tool regarding indentation for neovim is tabs-vs-spaces.nvim

  • VS Code / Codium

Since nimpretty_t is a niche project in the Nim community, it is not yet clear whether it will have a user base that can benefit from its own VS Code extension. To save efforts the extension has not yet been completed. Until then, please use the Run on Save extension from emeraldwalk.

jsonc // settings.json // ... "emeraldwalk.runonsave": { "commands": [ { "match": "\\.nim$", "isAsync": true, "cmd": "nimpretty_t -w ${file}" } ] }