All Projects → FedericoCeratto → nimfmt

FedericoCeratto / nimfmt

Licence: GPL-3.0 license
Nim code formatter / linter / style checker

Programming Languages

nim
578 projects

Projects that are alternatives of or similar to nimfmt

loco
Loco: Localization Package for Nim Apps
Stars: ✭ 20 (-73.33%)
Mutual labels:  nim-lang
vue-cli-template-library
Template for developing open-source vue.js libraries with Rollup + Jest + Babel + Storybook + TravisCI + SemanticRelease
Stars: ✭ 61 (-18.67%)
Mutual labels:  linter
yamburger
YAML syntax got you down? That's a YAMBURGER!
Stars: ✭ 32 (-57.33%)
Mutual labels:  linter
thermopi
A Nest-like intelligent thermostat implementation for the Raspberry Pi
Stars: ✭ 16 (-78.67%)
Mutual labels:  nim-lang
elm-lint
elm-lint lints Elm source code, to add additional guarantees to your project.
Stars: ✭ 27 (-64%)
Mutual labels:  linter
Husky.Net
Git hooks made easy with Husky.Net internal task runner! 🐶 It brings the dev-dependency concept to the .NET world!
Stars: ✭ 394 (+425.33%)
Mutual labels:  linter
typo3-typoscript-lint
Find coding errors in your TypoScript files.
Stars: ✭ 78 (+4%)
Mutual labels:  linter
prlint
GitHub App for linting pull request meta data
Stars: ✭ 122 (+62.67%)
Mutual labels:  linter
f2e-spec
Alibaba Front-end Coding Guidelines and Relevant Tools
Stars: ✭ 548 (+630.67%)
Mutual labels:  linter
vscode-linter
Extension for code linting, all in one package. New linters can be easily added through an extension framework.
Stars: ✭ 47 (-37.33%)
Mutual labels:  linter
livecore
A hardcore livecoding system for realtime audio synth.
Stars: ✭ 25 (-66.67%)
Mutual labels:  nim-lang
flake8-putty
Flake8 plugin to control reporting per file and line
Stars: ✭ 38 (-49.33%)
Mutual labels:  linter
repolint
Tool to check github user/organization repositories for some simple and common issues.
Stars: ✭ 19 (-74.67%)
Mutual labels:  linter
tryceratops
A linter to prevent exception handling antipatterns in Python (limited only for those who like dinosaurs).
Stars: ✭ 381 (+408%)
Mutual labels:  linter
nano-staged
Tiny tool to run commands for modified, staged, and committed files in a GIT repository.
Stars: ✭ 347 (+362.67%)
Mutual labels:  linter
spec
🐣 easy to use eslint/stylelint/tslint/prettier/...
Stars: ✭ 60 (-20%)
Mutual labels:  linter
nim-package-directory
Nim package directory - documentation builder
Stars: ✭ 47 (-37.33%)
Mutual labels:  nim-lang
ll
ll - a more informative `ls`, based on `k`
Stars: ✭ 24 (-68%)
Mutual labels:  nim-lang
nim-presentation-slides
Nim Presentation Slides and Examples.
Stars: ✭ 30 (-60%)
Mutual labels:  nim-lang
nim-mathexpr
Tiny math expression evaluator library implemented in pure Nim
Stars: ✭ 58 (-22.67%)
Mutual labels:  nim-lang

Nim code formatter / style checker

Features
  • ✓ Detect inconsistent variable and proc naming

  • ✓ Fix inconsistent variable and proc naming

  • ✓ Add/remove whitespaces and commas in function calls

  • ❏ Sort imports

  • ❏ Enforce variable/function naming style

  • Enforce whitelines (in fixed number or a range):

    • ❏ before functions

    • ❏ on closing blocks

    • ❏ end of file

    • ❏ around imports

  • ❏ Optional # to close blocks

One of the main features is to detect and correct inconsistent variable and function naming.

Using proc_naming_style = most_popular, if the same identifier appears within a file as myName more frequently and my_name and myname less frequently, nimfmt will pick the first one. This is the recommended setting to ensure consistency without having to explicitly configure nimfmt with a preferred style.

Using proc_naming_style = snake_case, if the same identifier appears as myName, my_name and myname, nimfmt will pick the second one.

Configuration

nimfmt looks for configuration files is the following order:
  • current directory

  • ~/.config/nimfmt.cfg

  • ~/.nimfmt.cfg

  • /etc/nimfmt.cfg

Configuration example:

# Fix inconsistent naming
# auto     - fix automatically
# no       - print warning only
fix_naming_style = "auto"

# Choose the correct naming
# most_popular  - pick the most frequently used naming style for a given identifier
# snake_case    - prefer snake_case naming if possible
proc_naming_style = most_popular

Examples

Input:

proc my_foo( a: string,  b:string,c:int, ): string  =
  raise newException ( Exception ,
    "foo" )
  foo ( a , b , c )
  d [ a ]  =  3
  discard    "string to discard"

  break
  return   "string to return"

Output:

proc my_foo(a: string; b: string; c: int): string =
  raise newException(Exception, "foo")
  foo(a, b, c)
  d[a] = 3
  discard "string to discard"
  break
  return "string to return"

Usage

  nimfmt <filename.nim> [<filename.nim> ... ]
  [ -p <prefix> ]     output file prefix
  [ -s <suffix> ]     output file suffix
  [ -c <filename>, ]  configuration file location(s) (default: ./.nimfmt.cfg ~/.nimfmt.cfg)
  [ -i ]              update files in-place (dangerous!)
  [ -w ]              overwrite existing files (automatically enabled when using -i)
  [-v]                version
  [-h]                this help

  If any of -p ..., -s ... or -i are specified the output will be written to disk,
  otherwise to stdout

Installation

nimble install https://github.com/FedericoCeratto/nimfmt
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].