CppCXY / EmmyLuaCodeStyle

fast, powerful, and feature-rich Lua formatting and checking tool.
MIT License
138 stars 26 forks source link

Preserve Spaces Before Single-Argument Function Call #157

Closed firas-assaad closed 8 months ago

firas-assaad commented 8 months ago

Usually I like to have a space before a function call with a single string or table argument, but I have a few special functions where I don't want to have spaces. For example:

function L(lambda_string)
    -- Turns the lambda string into a function
end

local f = L'x, y => x > y' -- the same as: local f = function(x, y) return x > y end

I realize this is a very specific use case, so I was wondering if there's a way to simply turn off the space_before_function_call_single_arg setting. Something like "keep" or "preserve".

Edit: ideally with different settings for tables and strings. I still want to always have a space before tables.

CppCXY commented 8 months ago

set space_before_function_call_single_arg=only_table

CppCXY commented 8 months ago

see https://github.com/CppCXY/EmmyLuaCodeStyle/blob/ebcd76a256ad5b36b9645ae89ca17360bafbdc2a/lua.template.editorconfig#L49C1-L52C47

firas-assaad commented 8 months ago

space_before_function_call_single_arg=only_table

I already tried. This removes the space before strings. e.g.

-- Before:
require 'file'

-- After:
require'file'

What I want is to not do anything if it's a string. Just keep it as it is if possible.

CppCXY commented 8 months ago

you can set space_before_function_call_single_arg.string = keep

CppCXY commented 8 months ago

If you want to get an early taste of this feature, you can compile it yourself, or wait for me to release a version in a few days.

firas-assaad commented 8 months ago

Thank you so much for adding this option (and the one for continuation too). I'll wait for the release.