Commit Graph

38 Commits

Author SHA1 Message Date
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
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
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
7fe27fa7ca Fixing annoying edge cases 2015-08-05 20:13:07 +09:00
7c300e80f7 Don't match perens in comments 2015-07-09 13:45:47 +09:00
e111ac083a Handle wrapping of empty braces in a better way 2015-03-26 18:28:22 +09:00
b7fc4d414f Make changes work with buffers 2015-03-25 14:31:14 +09:00
ebe4380188 Adding g:argwrap_wrap_closing_brace , getting rid of g_argwrap_wrap_style 2015-03-25 14:17:45 +09:00
a899077bf5 Better handling of spaces during unwrapping. 2015-03-12 15:45:46 +09:00
93284608cc Improved trimming around = and : characters 2015-02-20 13:03:38 +09:00
a25bb6ad76 Trimming spaces when unwrapping dictionary definitions. 2015-02-19 13:00:02 +09:00
d674676c7d No longer support passing arguments to toggle function 2015-01-28 23:10:23 +09:00
d8a137ace5 Revert "Adding ArgWrap command"
This reverts commit c4b0c13a6d.
2015-01-28 20:45:56 +09:00
c4b0c13a6d Adding ArgWrap command 2015-01-28 20:26:57 +09:00
ae18d6d987 Adding option to add space padding inside of braces; adding global option for wrap style 2015-01-28 13:40:42 +09:00
3b0dc93b22 Fixing default argument 2014-12-07 12:32:31 +09:00
0b9a40b45f Properly handle tabs 2014-12-03 13:44:31 +09:00
c5f010787e Adding bx style wrapping 2014-12-03 10:34:28 +09:00
b3a2560c59 More fixups to paren matching 2014-12-02 19:25:08 +09:00
a3caecbd6a Early out when no arguments, store cursor position 2014-12-02 12:31:44 +09:00
164ca21b71 Fixing argument wrapping 2014-12-02 12:22:50 +09:00
a5f67f6213 Getting rid of annoying log message 2014-12-02 12:18:15 +09:00
897535d60b Better paren matching 2014-12-02 12:15:21 +09:00
1572562998 More cleanup 2014-12-02 09:57:39 +09:00
b948dbb2d6 Cleanup 2014-12-02 09:36:14 +09:00
f07af29b99 Cleanup for Pathogen 2014-12-02 06:25:47 +09:00