Skip to content

Add call_parentheses = "Never" option - #1161

Open
ignamartinoli wants to merge 1 commit into
JohnnyMorganz:mainfrom
ignamartinoli:call-parentheses-never
Open

ignamartinoli wants to merge 1 commit into
JohnnyMorganz:mainfrom
ignamartinoli:call-parentheses-never

Conversation

@ignamartinoli

Copy link
Copy Markdown

With call_parentheses = "None", parentheses are kept when the call is followed by an index or method call, since removing them can look like the index applies to the argument:

local lib = require("lib").setup

This adds a Never option that behaves like None but removes parentheses in those cases too:

local lib = require "lib".setup
foo { x = 1 }:bar()

The output is still valid Lua with the same semantics (require "lib".setup indexes the call result).

  • Available via stylua.toml, --call-parentheses never, and .editorconfig
  • README and CHANGELOG updated
  • Added a test in tests/test_call_parentheses.rs

Behaves like `None`, but also removes parentheses when the call is
followed by an index or method call, e.g.
`require("lib").setup -> require "lib".setup`.
@ignamartinoli

Copy link
Copy Markdown
Author

This PR should also fix #1009

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant