Commit Graph

112 Commits

Author SHA1 Message Date
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
Alex Yatskov
d52b2104e1
Merge pull request #21 from elythyr/fix-prefix-ending-with-space
fix: prefix ending with spaces
2020-06-06 15:13:35 -07:00
Alex Yatskov
92c418f57b
Merge pull request #22 from elythyr/improvement-repeat
improvement: allow to repeat with .
2020-06-06 14:16:30 -07:00
Camille Dejoye
51806e3548 improvement: allow to repeat with . 2020-06-06 16:19:38 +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
7e3db5f517 Updating README.md 2019-04-28 12:34:49 -07:00
440b74c919 Merge branch 'master' of https://github.com/FooSoft/vim-argwrap 2019-04-28 11:46:11 -07:00
377883cc29 update license file 2019-04-28 11:46:05 -07:00
9ed7a803a4 Updating README.md 2019-01-05 19:44:15 -08:00
Alex Yatskov
f0f360e86a
Merge pull request #18 from jeetsukumaran/master
Seamless Toggling of Wrapped/Unwrapped States
2018-05-26 09:49:49 -07: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
93d1a33400 updating docs 2018-03-31 14:28:16 -07:00
15bae033dc Updating README.md 2018-03-31 10:54:06 -07:00
86dd7aecc5 add tail_indent_braces and comma_first_indent 2018-03-30 10:06:27 -07:00
041a48b28f Updating README.md 2017-10-02 21:06:01 -07:00
75f5bb722d Updating README.md 2017-07-30 17:37:54 -07:00
Alex Yatskov
ef097b2478 Merge pull request #13 from amsayk/patch-1
Silence `1 line ed> 1 time` messages when wrapping.
2017-06-30 21:43:22 -07:00
Amadou Cisse
118c3fb9a4 Silence 1 line ed> 1 time messages when wrapping. 2017-07-01 01:41:17 +00:00
Alex Yatskov
135bb7b31e Merge pull request #12 from fsareshwala/master
readme: fix tail comma disabled example
2017-06-07 13:22:19 -07:00
Faraaz Sareshwala
ca7e69fdaa readme: fix tail comma disabled example 2017-06-07 12:14:44 -07:00
03a29b3e6c Merge branch 'master' of https://github.com/FooSoft/vim-argwrap 2016-10-25 19:15:56 -07:00
7172e62d99 Updating README.md 2016-10-25 19:15:48 -07:00
Alex Yatskov
6bd761a05c Merge pull request #10 from iamFIREcracker/tail-comma-braces
Add new configuration variable tail_comma_braces
2016-10-12 19:13:49 -07: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
112a28c888 Updating README.md 2016-09-06 21:16:36 -07:00
4c49898d58 Updating README.md 2016-09-06 21:14:15 -07:00
7e5465a2ff Updating readme 2016-07-10 13:43:09 -07:00
7173da45d5 Updating README.md 2016-07-10 13:39:41 -07:00
df53974e15 Updating README.md 2016-07-07 22:30:58 -07:00
7df71f8bfd Updating README.md 2016-07-02 23:55:11 -07:00
a12428749f Merge branch 'master' of https://github.com/FooSoft/vim-argwrap 2016-07-02 21:41:36 -07:00
1ee4acd017 Deleting images 2016-07-02 21:41:23 -07:00
068637fb62 Support commaFirst option 2016-06-01 22:19:00 -07:00
cfe10c45a8 Fixing conflicting options #5 2016-05-19 09:21:17 -07:00
4057c955bc Updating docs to reflect new features 2015-12-17 22:03:08 +09:00
bf3da537eb Add support for line prefixes 2015-12-17 20:23:45 +09:00
a83fdc725d Add support for trailing commas 2015-12-17 19:18:39 +09:00
Alex Yatskov
0b69dd51a5 Update README.md 2015-11-17 14:21:21 +09:00
5f6ffcc360 Updating README 2015-11-13 18:45:29 +09:00
bb599e5126 Updating readme 2015-08-19 18:56:11 +09:00
d790b83664 Updating doc 2015-08-19 18:26:56 +09:00
e143792bd8 Updating doc 2015-08-19 18:24:27 +09:00
a610a83972 Updating doc 2015-08-19 18:20:19 +09:00