1
Fork 0
Commit Graph

45 Commits

Author SHA1 Message Date
Eric T. Johnson 1a4a2d4c7c
Match the inner brace scope when on an opening bracket
Fixes #3.
2023-09-22 13:17:58 -04:00
Camille Dejoye 8585d3f256 remove remaining spaces at the end of the line after unwrapping 2020-11-21 10:25:27 +01:00
Camille Dejoye 2c997ed781 Fix PHP smart brace hook for static method 2020-11-17 13:48:57 +01:00
Camille Dejoye 7afc8ac1cd improvement: preserve the cursor position
The idea was to be able to keep the cursor on the same position than
before an operation.
To solve this issue I first extract the position of the cursor, this
position is given relative to the argument list. It contains the number
of the argument and a column number relative to the start of the
argument.
This way it is possible to position the cursor later on and I hope it
should be pretty easy for any extension to adapt it if needed since it's
provided in the container dictionary.
2020-06-13 13:11:24 +02:00
Camille Dejoye b0e60c9cd1 improvement: globally initialize the settings
The settings were initialize in an autoload which is not a good
practice.
So I initialize them in the plugin directly, this way there are
initialize only once when the plugin is loaded and they can be access
anywhere without having to worry about what the default value.
2020-06-13 12:21:03 +02:00
Camille Dejoye eff4334368 fix: execution order of post hooks
The hooks were executed in the same order regarding of if they were pre
or post hooks.
This is actually not a correct behavior, let's assume we want to create
a hook responsible for keeping the position of the cursor between
operations:
The pre hook will have to extract the current position of the cursor and
therefore should be the first one to be executed, let's say we gave it a
priority 0.
The post hook will have to reposition the cursor after the
transformation and therefore should be the last one to be executed.
That's why we need to reverse the order of the post hooks.
2020-06-13 11:28:30 +02:00
Camille Dejoye 12ea40a812 fix: php smart brace with return type hint 2020-06-07 17:00:00 +02:00
Camille Dejoye 0fc75c596c improvement: generalize the hook system
It is still not possible to override an existing hook but with this
system users can create new hooks really simply without having to update
any configuration since they will be autodetected.

The only missing thins is the possibility to disable hook, therefore it
is the responsibility of each hook to provide a way to the user to use
it or not.
2020-06-07 15:26:06 +02:00
Camille Dejoye 18621cafcb improvement: add a filetype hook for PHP
This solve the issue #19
I put it there as an example, it might be better in its own repository.
This way a user will be able to choose to use it or not, which will
allow them to be able to provide their own implementation.

This attempt only deal with methods.
Functions are not part of the PSR-2.
Closures should always have the opening brace on the same line as the
closing parenthesis, this extension is not a CS fixer and therefore as
no reason to deal with them.
2020-06-07 10:58:28 +02:00
Camille Dejoye f7e39155de improvement: trigger post hooks after wrap/unwrap
A first step to make the plugin extendable.
This allow to add logic on a per filetype basis.

This solution allow a user to extend the behavior if the plugin does not
provide a hook for the given filetype.
But if there is already a hook then the user can not create it's own.

One solution could be to find every functions defined in the namespace
`argwrap#hooks#user#<ANYTHING>#post_wrap`, I think airline provide a
feature like this.
Those hooks would need to be sorted in order to have a predictible
behavior, also it might be interesting to provide a way for each hook to
update the range, container and arguments.
There might be nothing to do because I think Vim's lists and dictionaries
are passed by reference.
2020-06-07 10:20:29 +02:00
Camille Dejoye 6c240beb01 fix: prefix ending with spaces
For example in VimL with the following declaration:
autocmd FileType vim let b:argwrap_line_prefix = '\ '

The following line will be properly wrapped:
let t = {'one': 'whatever', 'two': 'whatever'}

Into:
let t = {
  \ 'one': 'whatever',
  \ 'two': 'whatever',
\ }

But when trying to unwrap it will do:
let t = {'one': 'whatever', 'two': 'whatever', \}

This is caused by the "trim" done for each "extracted" piece of text,
which result in having '\' instead of '\ ' for the last line.
2020-06-06 15:16:27 +02:00
Jeet Sukumaran 2ca601e10b When wrapping, move to first line inside container.
This (in combination with previous patch) allows for seamless back-and-forth toggling between wrapped and
unwrapped states.
2018-05-26 11:08:07 -04:00
Jeet Sukumaran 30edd6ba0a Stay in container line when unwrapping (for spatial idempotency) 2018-05-26 11:03:30 -04:00
Alex Yatskov 86dd7aecc5 add tail_indent_braces and comma_first_indent 2018-03-30 10:06:27 -07:00
Amadou Cisse 118c3fb9a4 Silence `1 line ed> 1 time` messages when wrapping. 2017-07-01 01:41:17 +00:00
Matteo Landi 5868d3205d Use the last char of container.prefix as match expression 2016-10-12 23:49:06 +02:00
Matteo Landi 9beff4da68 Add new setting: argwrap_tail_comma_braces 2016-10-12 23:23:20 +02:00
Alex Yatskov 068637fb62 Support commaFirst option 2016-06-01 22:19:00 -07:00
Alex Yatskov cfe10c45a8 Fixing conflicting options #5 2016-05-19 09:21:17 -07:00
Alex Yatskov 4057c955bc Updating docs to reflect new features 2015-12-17 22:03:08 +09:00
Alex Yatskov bf3da537eb Add support for line prefixes 2015-12-17 20:23:45 +09:00
Alex Yatskov a83fdc725d Add support for trailing commas 2015-12-17 19:18:39 +09:00
Alex Yatskov 7fe27fa7ca Fixing annoying edge cases 2015-08-05 20:13:07 +09:00
Alex Yatskov 7c300e80f7 Don't match perens in comments 2015-07-09 13:45:47 +09:00
Alex Yatskov e111ac083a Handle wrapping of empty braces in a better way 2015-03-26 18:28:22 +09:00
Alex Yatskov b7fc4d414f Make changes work with buffers 2015-03-25 14:31:14 +09:00
Alex Yatskov ebe4380188 Adding g:argwrap_wrap_closing_brace , getting rid of g_argwrap_wrap_style 2015-03-25 14:17:45 +09:00
Alex Yatskov a899077bf5 Better handling of spaces during unwrapping. 2015-03-12 15:45:46 +09:00
Alex Yatskov 93284608cc Improved trimming around = and : characters 2015-02-20 13:03:38 +09:00
Alex Yatskov a25bb6ad76 Trimming spaces when unwrapping dictionary definitions. 2015-02-19 13:00:02 +09:00
Alex Yatskov d674676c7d No longer support passing arguments to toggle function 2015-01-28 23:10:23 +09:00
Alex Yatskov d8a137ace5 Revert "Adding ArgWrap command"
This reverts commit c4b0c13a6d.
2015-01-28 20:45:56 +09:00
Alex Yatskov c4b0c13a6d Adding ArgWrap command 2015-01-28 20:26:57 +09:00
Alex Yatskov ae18d6d987 Adding option to add space padding inside of braces; adding global option for wrap style 2015-01-28 13:40:42 +09:00
Alex Yatskov 3b0dc93b22 Fixing default argument 2014-12-07 12:32:31 +09:00
Alex Yatskov 0b9a40b45f Properly handle tabs 2014-12-03 13:44:31 +09:00
Alex Yatskov c5f010787e Adding bx style wrapping 2014-12-03 10:34:28 +09:00
Alex Yatskov b3a2560c59 More fixups to paren matching 2014-12-02 19:25:08 +09:00
Alex Yatskov a3caecbd6a Early out when no arguments, store cursor position 2014-12-02 12:31:44 +09:00
Alex Yatskov 164ca21b71 Fixing argument wrapping 2014-12-02 12:22:50 +09:00
Alex Yatskov a5f67f6213 Getting rid of annoying log message 2014-12-02 12:18:15 +09:00
Alex Yatskov 897535d60b Better paren matching 2014-12-02 12:15:21 +09:00
Alex Yatskov 1572562998 More cleanup 2014-12-02 09:57:39 +09:00
Alex Yatskov b948dbb2d6 Cleanup 2014-12-02 09:36:14 +09:00
Alex Yatskov f07af29b99 Cleanup for Pathogen 2014-12-02 06:25:47 +09:00