Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Question/Feature Request]: chop_down_parameter and align_parameter #247

Open
lmburns opened this issue Apr 13, 2022 · 0 comments
Open

[Question/Feature Request]: chop_down_parameter and align_parameter #247

lmburns opened this issue Apr 13, 2022 · 0 comments

Comments

@lmburns
Copy link

lmburns commented Apr 13, 2022

Configuration
column_limit: 90
indent_width: 2
use_tab: false
tab_width: 4
continuation_indent_width: 4
keep_simple_control_block_one_line: false
keep_simple_function_one_line: false
align_args: true
align_parameter: false
align_table_field: true
spaces_before_call: 1
spaces_inside_functioncall_parens: false
spaces_inside_functiondef_parens: false
spaces_inside_table_braces: true
spaces_around_equals_in_field: true
chop_down_parameter: true
chop_down_table: true
chop_down_kv_table: true
break_after_functioncall_lp: true
break_before_functioncall_rp: true
break_after_functiondef_lp: true
break_before_functiondef_rp: true
break_after_table_lb: true
break_before_table_rb: true
break_after_operator: true
table_sep: ","
extra_sep_at_table_end: true
double_quote_to_single_quote: false
single_quote_to_double_quote: true
line_breaks_after_function_body: 1

column_table_limit: 80
line_separator: lf

Example 1

If I have something like the following:

Issue
map(
    "t", self.cfg.layout_mapping, function()
      api.nvim_win_set_config(
          self.winid, M.get_view(self.cfg.views[g.__lf_layout_idx])
      )
      g.__lf_layout_idx = g.__lf_layout_idx < #self.cfg.views and g.__lf_layout_idx +
                              1 or 1
    end
)

How could I get it to break each parameter onto its own line (similar to something like rustfmt)
I've tried modifying several configuration options but could not get it to work. I thought
the most relevant options here would be chop_down_parameter and align_parameter, but they don't
do what I was expecting.

Maybe another option could be given to the configuration

Solution
map(
    "t",
    self.cfg.layout_mapping,
    function()
      api.nvim_win_set_config(
          self.winid, M.get_view(self.cfg.views[g.__lf_layout_idx])
      )
      g.__lf_layout_idx = g.__lf_layout_idx < #self.cfg.views and g.__lf_layout_idx +
                              1 or 1
    end
)

For instance lua-fmt breaks down each line, but lacks
configurability.


Example 2

I have something like:

Issue
self.term.cmd = ([[%s -last-dir-path='%s' -selection-path='%s' %s]]):format(
    self.term.cmd, self.lastdir_tmp, self.lf_tmp, self.term.dir
)

I would expect that an option in the configuration file could 'chop' down each parameter
onto its own line resulting in something like:

Solution
self.term.cmd =
    ([[%s -last-dir-path='%s' -selection-path='%s' %s]]):format(
    self.term.cmd,
    self.lastdir_tmp,
    self.lf_tmp,
    self.term.dir
)

On a side note, I see the Chop down operators #205 issue, which would make the call look even nicer

Like
map(
    "t",
    self.cfg.layout_mapping,
    function()
      api.nvim_win_set_config(
          self.winid, M.get_view(self.cfg.views[g.__lf_layout_idx])
      )
      g.__lf_layout_idx = g.__lf_layout_idx < #self.cfg.views
                              and g.__lf_layout_idx + 1
                              or 1
    end
)
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

No branches or pull requests

1 participant