Commit Graph

127 Commits

Author SHA1 Message Date
Alexei Yatskov b532cb6805
Merge pull request #32 from yut23/patch-1
Match the inner brace scope when on an opening bracket
2023-09-23 16:04:48 -07:00
Eric T. Johnson 1a4a2d4c7c
Match the inner brace scope when on an opening bracket
Fixes #3.
2023-09-22 13:17:58 -04:00
Alex Yatskov feaba6b8b6 Update README 2022-07-14 14:23:00 -07:00
Alex Yatskov 0faba07179 Update README 2022-02-07 19:59:30 -08:00
Alex Yatskov 0c03483702 Update readme 2022-02-05 18:13:20 -08:00
Alex Yatskov c5de0769d8 Update README 2021-12-15 18:05:19 -08:00
Alex Yatskov 0621273b74 Add site metadata 2021-12-14 20:01:17 -08:00
Alex Yatskov f1c1d2b0c7
Merge pull request #27 from camilledejoye/fix/php-smart-brace-handle-static-methods
Fix PHP smart brace hook for static method
2021-06-10 21:03:48 -07:00
Alex Yatskov 8f963a11a3 Update README 2021-06-08 21:01:21 -07: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
Alex Yatskov f3d122d9b1
Merge pull request #24 from elythyr/improvement-preserve-cursor-position
Improvement preserve cursor position
2020-06-26 20:06:32 -07:00
Alex Yatskov 878e9c872d
Merge pull request #23 from elythyr/improvement-hooks
improvement: hooks & PHP open brace handling for methods
2020-06-26 20:05:22 -07: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 209ae8f20a doc: update the doc for the order of hooks 2020-06-13 12:46:57 +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
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
Alex Yatskov 7e3db5f517 Updating README.md 2019-04-28 12:34:49 -07:00
Alex Yatskov 440b74c919 Merge branch 'master' of https://github.com/FooSoft/vim-argwrap 2019-04-28 11:46:11 -07:00
Alex Yatskov 377883cc29 update license file 2019-04-28 11:46:05 -07:00
Alex Yatskov 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
Alex Yatskov 93d1a33400 updating docs 2018-03-31 14:28:16 -07:00
Alex Yatskov 15bae033dc Updating README.md 2018-03-31 10:54:06 -07:00
Alex Yatskov 86dd7aecc5 add tail_indent_braces and comma_first_indent 2018-03-30 10:06:27 -07:00
Alex Yatskov 041a48b28f Updating README.md 2017-10-02 21:06:01 -07:00
Alex Yatskov 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
Alex Yatskov 03a29b3e6c Merge branch 'master' of https://github.com/FooSoft/vim-argwrap 2016-10-25 19:15:56 -07:00
Alex Yatskov 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
Alex Yatskov 112a28c888 Updating README.md 2016-09-06 21:16:36 -07:00
Alex Yatskov 4c49898d58 Updating README.md 2016-09-06 21:14:15 -07:00
Alex Yatskov 7e5465a2ff Updating readme 2016-07-10 13:43:09 -07:00
Alex Yatskov 7173da45d5 Updating README.md 2016-07-10 13:39:41 -07:00