GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — GitHub - LuaDevelopmentTools/luaformatter: Beautifies Lua code

BranchesTags
Open more actions menu

Latest commit

 

History

20 Commits
20 Commits

Folders and files

NameName
Last commit message
Last commit date
luarocks
luarocks
 
 
CHANGELOG.md
CHANGELOG.md
 
 
LICENSE
LICENSE
 
 
README.md
README.md
 
 
commandline.lua
commandline.lua
 
 
formatter.lua
formatter.lua
 
 

Repository files navigation

Lua Formatter

This library beautify Lua code:

  • Indent block
  • Indent expressions
  • Trim trailing white spaces

It is plain Lua 5.1.

Prerequisites

  • Lua 5.1
  • Metalua >= 0.7
  • Penlight ~> 0.9

Installation

$ luarocks install --local formatter

How does it work?

Library

$ lua
Lua 5.1.5  Copyright (C) 1994-2012 Lua.org, PUC-Rio
> formatter = require 'formatter'
> code = [[do
>> local var = 
>> 42
>> end]]
> formattedcode = formatter.indentcode(code, '\n', true, '  ')
> print( formattedcode )
do
  local var =
    42
end

Command line

$ cat sample.lua
do
local var =
42
end
$ luaformatter sample.lua
do
  local var =
    42
end

Want more options?

$ luaformatter --help
Formats Lua code.
  -a, --autosave Flush formatted Lua in given file instead of stdout.
  -s, --spaces (default 2) Spaces to use as indentation.
  -t, --tabs   (default 0) Tabulation(s) to use as indentation.
  -d, --delimiter (default unix) Type of new line to detect and use while formatting:
    * unix: '\n' LF Line feed.
    * windows: '\r\n' CR+LF
    * mac: '\r' CR Carriage Return of Macs before OSX.
  -h, --help This help.
  [files] Files to format.

About

Beautifies Lua code

Resources

Readme
EPL-1.0 license
Activity
Custom properties

Stars

37 stars

Watchers

3 watching

Forks

6 forks
Report repository

Releases

Packages

Contributors

Languages

You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.