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

Feature request: Option to specify indentation for parameters on multi-line function calls #71

Closed
bendoh opened this issue Jun 20, 2019 · 1 comment
Assignees
Labels

Comments

@bendoh
Copy link

bendoh commented Jun 20, 2019

I'm working with a particular standard that isn't supported by this current version but I think could be fairly easily be made as an option.

The standard is: parameters for multi-line function calls receive an additional level of indentation.

For example, instead of

function f() {
  $this->function(
      $param1,
      $param2,
      [
        'key1' => 1,
        'key2' => 2
      ]
  );
}

Essentially, this just means that if the previous line ends with something that looks like a function call, [\w_]\+($, we add one more level of indentation.

A cursory glance at the plugin suggests to me that adding such an option to this indentation engine wouldn't be much of a stretch, and could be configured in a variable, e.g.,

let g:PHP_IndentFunctionParameters = 2

2072 added a commit that referenced this issue Jun 30, 2019
…ers to be set to the number of additional indents you want for your function parameters.
@2072
Copy link
Owner

2072 commented Jun 30, 2019

So you want the above code to look like this:

function f() {
  $this->validFunctionName( // note that if you use 'function' as your function name, the indent script will not work 
          $param1,
          $param2,
          [
            'key1' => 1,
            'key2' => 2
          ]
      );
}

I had to implement proper searchpair matching for closing ) and ] for this option to be possible but it's a good thing in the end so thank you for this request, it made me fix a very old issue that was disregarded a long time ago because it used to be too slow... (15 years ago!)

So I've added the option PHP_IndentFunctionParameters. You can set it globally, before loading a file, or per buffer, at anytime, using let b:PHP_IndentFunctionParameters.

I've tested this new option a little bit but more testing would be very valuable so if you could confirm that it works well for you it would be very appreciated.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants