LuaFormatter
LuaFormatter copied to clipboard
Request: column_table_limit_kv
column_table_limit_kv
type: int, default: column_table_limit
The column limit of each line of a k = vtable. Default value the same as column_table_limit value.
This will allow me to keep my arrays on a longer line but split up dictionary mappings
Could you provide an example of before/after?
before
local a = {"one"', "two", "three"}
local b = {one = true, two = true, three = true}
column_table_limit = 40 column_table_limit_kv = 10
After
local a = {"one"', "two", "three"}
local b = {
one = true,
two = true,
three = true
}
On Fri, Oct 16, 2020, 2:25 PM Pedro Tammela [email protected] wrote:
Could you provide an example of before/after?
— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/Koihik/LuaFormatter/issues/144#issuecomment-710376261, or unsubscribe https://github.com/notifications/unsubscribe-auth/ADKTFYBCNDT4AIIGI47JQ3TSLCF2ZANCNFSM4SMAJ44A .
same as https://github.com/Koihik/LuaFormatter/issues/98
Not quite the same, column_table_limit affects both dictionary and array type tables.
column_limit: &1 120
indent_width: 4
continuation_indent_width: 4
align_table_field: false
break_after_table_lb: true
break_before_table_rb: true
column_table_limit: 30
chop_down_table: false
chop_down_kv_table: true
Input / Expected Output column_table_limit_kv=10, column_table_limit = 120:
local a = {"one", "one", "one", "one", "one", "one", "one", "one", "one", "one", "one", "one", "one", "one"}
local blacklist_types = {
['item-request-proxy'] = true,
['rocket-silo-rocket'] = true,
['resource'] = true,
['construction-robot'] = true,
['logistic-robot'] = true,
['rocket'] = true,
['tile-ghost'] = true,
['item-entity'] = true
}
local oblong_entities = {
['arithmetic-combinator'] = true,
['decider-combinator'] = true,
['pump'] = true
}
Output: with column_table_limit=30
local a = {
'one', 'one', 'one',
'one', 'one', 'one',
'one', 'one', 'one',
'one', 'one', 'one',
'one', 'one'
}
local blacklist_types = {
['item-request-proxy'] = true,
['rocket-silo-rocket'] = true,
['resource'] = true,
['construction-robot'] = true,
['logistic-robot'] = true,
['rocket'] = true,
['tile-ghost'] = true,
['item-entity'] = true
}
local oblong_entities = {
['arithmetic-combinator'] = true,
['decider-combinator'] = true,
['pump'] = true
}
Output: with colum_table_limit=120
local a = {'one', 'one', 'one', 'one', 'one', 'one', 'one', 'one', 'one', 'one', 'one', 'one', 'one', 'one'}
local blacklist_types = {
['item-request-proxy'] = true,
['rocket-silo-rocket'] = true,
['resource'] = true,
['construction-robot'] = true,
['logistic-robot'] = true,
['rocket'] = true,
['tile-ghost'] = true,
['item-entity'] = true
}
local oblong_entities = {['arithmetic-combinator'] = true, ['decider-combinator'] = true, ['pump'] = true}
Hi @tammela @Koihik A new setting for KV tables is desirable as KV tables read better if they are chopped down, while Normal tables read better if multiple rows are aligned (with more than one item in a row). Since chop down settings are different for normal and KV tables, it would make sense to add a separate config for line limit for KV tables. Is there any plan to work on this?
Moreover, a table should be chopped down even if it does not breach the table limit. If the chop setting is off, then honor the limit and group as many items on a line/row as you can and move to the next line. It is kind of counter intuitive to have a chop down config boolean only to be restricted by another line limit config. Just my 2 cents on the topic though.
I wouldn't mind if the line breaks in tables where kept. If I decided to put line breaks after each first level table entry then it should be possible to keep those and not reformat them to one line if the column width happens to be shorter.
Lines should really only be reformatted if it is longer than configured not shorter.