Code Monkey home page Code Monkey logo

plugin-lua's Introduction

Prettier Banner

Opinionated Code Formatter

JavaScript · TypeScript · Flow · JSX · JSON
CSS · SCSS · Less
HTML · Vue · Angular
GraphQL · Markdown · YAML
Your favorite language?

Github Actions Build Status Github Actions Build Status Github Actions Build Status Codecov Coverage Status Blazing Fast
npm version weekly downloads from npm code style: prettier Follow Prettier on Twitter

Intro

Prettier is an opinionated code formatter. It enforces a consistent style by parsing your code and re-printing it with its own rules that take the maximum line length into account, wrapping code when necessary.

Input

foo(reallyLongArg(), omgSoManyParameters(), IShouldRefactorThis(), isThereSeriouslyAnotherOne());

Output

foo(
  reallyLongArg(),
  omgSoManyParameters(),
  IShouldRefactorThis(),
  isThereSeriouslyAnotherOne(),
);

Prettier can be run in your editor on-save, in a pre-commit hook, or in CI environments to ensure your codebase has a consistent style without devs ever having to post a nit-picky comment on a code review ever again!


Documentation

Install · Options · CLI · API

Playground


Badge

Show the world you're using Prettiercode style: prettier

[![code style: prettier](https://img.shields.io/badge/code_style-prettier-ff69b4.svg?style=flat-square)](https://github.com/prettier/prettier)

Contributing

See CONTRIBUTING.md.

plugin-lua's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

plugin-lua's Issues

Don't break local statement initializer onto next line

current output

local variable =
	call_something_that_is_kind_of_long(with_some_long, arguments_that_are_long)

expected output

local variable = call_something_that_is_kind_of_long(
	with_some_long,
	arguments_that_are_long
)

Project should be marked as Not Actively Maintained

The first line of the Readme states that this is a "🚧 Work in Progress! 🚧", and the first sentence states that "this plugin is ... still under active development." However, the last PR was merged in July of 2023, and the top of the issue list are items from 2021 that have not received any response or indications of review. The repo's primary author stated in April of 2023 on #16 that "I'm not really maintaining this these days."

If this repo is not in fact under active development or maintainenance, the readme should be changed to indicate that.

I apologize if I'm offending anyone by mentioning this. If my assesment of the state of the project is incorrect I will happily close this issue. Please also note that I'm not asking anyone to actively maintain this project, merely stating that its current status is not well reflected by the Readme.

When block string is the only argument to a call expression, it should hug

current output

	assert(
		context:ReturnBabel(
			[[
				fetch("asset://garrysmod/data/a.txt")
				.then((response) => response.text())
				.then(a => console.log(a))
				.catch(a => console.warn(a))
			]]
		):await()
	)

expected output

	assert(
		context:ReturnBabel([[
				fetch("asset://garrysmod/data/a.txt")
				.then((response) => response.text())
				.then(a => console.log(a))
				.catch(a => console.warn(a))
			]]):await()
	)

TypeError: options.locEnd is not a function

rtp.lua[error] rtp.lua: TypeError: locEnd is not a function
[error] at isNextLineEmpty (/usr/lib/node_modules/prettier/index.js:3572:42)
[error] at /usr/lib/node_modules/@prettier/plugin-lua/src/printer.js:410:7
[error] at /usr/lib/node_modules/prettier/index.js:14487:23
[error] at FastPath.each (/usr/lib/node_modules/prettier/index.js:14474:7)
[error] at FastPath.map (/usr/lib/node_modules/prettier/index.js:14486:10)
[error] at printBody (/usr/lib/node_modules/@prettier/plugin-lua/src/printer.js:384:8)
[error] at printNoParens (/usr/lib/node_modules/@prettier/plugin-lua/src/printer.js:28:14)
[error] at Object.genericPrint [as print] (/usr/lib/node_modules/@prettier/plugin-lua/src/printer.js:763:19)
[error] at callPluginPrintFunction (/usr/lib/node_modules/prettier/index.js:14718:18)
[error] at /usr/lib/node_modules/prettier/index.js:14649:47

Long if statement doesn't break

Current output:

if variable == some.nested.object and variable2 == another.object or variable == another.object and variable2 == some.nested.object then return end

Expected something like that:

if variable == some.nested.object and variable2 == another.object or
    variable == another.object and variable2 == some.nested.object then 
	return 
end

how to use programmatically?

I'd like to use this in the browser, however, trying it out with

  • "@prettier/plugin-lua": "0.0.1",
  • "prettier": "^2.2.1"
const prettier = require("prettier");
const plugin = require("@prettier/plugin-lua");

function format_lua(s) {
  return prettier.format(s, { parser: "lua" });
}

format_lua("function deepcopy(orig)
  local orig_type = type(orig)
     local copy

  if orig_type == 'table' then; copy = {}
  for orig_key, orig_value in next, orig, nil do
  copy[deepcopy(orig_key)] = deepcopy(orig_value)
          end
          setmetatable(
            copy,
            deepcopy(
              getmetatable(orig)))
      else
          copy = orig
      end
    return copy
  end")

gives:

format_lua("function deepcopy(orig)
           ^^^^^^^^^^^^^^^^^^^^^^^^

SyntaxError: Invalid or unexpected token
    at wrapSafe (node:internal/modules/cjs/loader:1024:16)
    at Module._compile (node:internal/modules/cjs/loader:1072:27)
    at Object.Module._extensions..js (node:internal/modules/cjs/loader:1137:10)
    at Module.load (node:internal/modules/cjs/loader:973:32)
    at Function.Module._load (node:internal/modules/cjs/loader:813:14)
    at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:76:12)
    at node:internal/main/run_main_module:17:47

Binary expressions should break better

current output

do
	ent = function(sock)
		local contents =
			"ENT = {}; local ENT=ENT; " .. sock:receive(
				"*a"
			) .. "; scripted_ents.Register(ENT, '" .. who:sub(0, -5) .. "')"
	end
end

expected output

do
	ent = function(sock)
		local contents =
			"ENT = {}; local ENT=ENT; "
				.. sock:receive("*a")
				.. "; scripted_ents.Register(ENT, '"
				.. who:sub(0, -5)
				.. "')"
	end
end

Rename to plugin-lua

@vjeux After transferring this repo to the prettier org, I no longer have access to its "Settings" tab, so I can't rename it to plugin-lua to match the other repos. Could you either rename it for me or give me access (if you know how)? Also could you verify @SpiralP and I both still have write access to the repo?

Sorry to bother you 😅

Necessary parentheses are removed

Input:

function x:PosToAbsolute( x, y )
    return ( x - 1 ) * self.width, ( y - 1 ) * self.height
end

Output:

function x:PosToAbsolute( x, y )
    return x - 1 * self.width, y - 1 * self.height -- <<== no parentheses
end

prettier-ignore has no effect

Adding -- prettier-ignore comment seems to have no effect.

The same with:

-- prettier-ignore-start
code
-- prettier-ignore-end

also with --[[ --]] block comments.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.