Code Monkey home page Code Monkey logo

vim-argwrap's Introduction

Leaving GitHub

I'm migrating my open source work away from GitHub. Individual project pages will soon be updated to reflect this change. Once the migration is complete, all repositories will be archived and will receive no further updates.

My projects now live at git.foosoft.net.

vim-argwrap's People

Contributors

camilledejoye avatar foosoft avatar fsareshwala avatar iamfirecracker avatar jeetsukumaran avatar therealcisse avatar yut23 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

vim-argwrap's Issues

[Feature request] First element on same line as opening parenthesis

First of all, love the package! Finally no more jJjJjJ... or s<enter>lls<enter> anymore! :)

I would love to use the following style (especially in function arguments):

Foo(text='hi',
    num=3,
    **kwargs)

But could not find how to do it with the current status of the project.

The closing parenthesis on the same line is already possible with the option let g:argwrap_wrap_closing_brace = 0. Would it be possible to add an option like let g:argwrap_wrap_opening_brace = 0 or something like that for the opening parenthesis?

I can try to create a PR implementing this, but don't have much experience with vimscript.

Thank you in advance!

Request: Align all arguments and closing parenthesis.

This code:

	int32_t prettify(char* _out, int32_t _count, uint64_t _value, Units::Enum _units = Units::Kibi);

with default argwrap behavior for leading comma arguments produces following:

	int32_t prettify(
		char* _out
		, int32_t _count
		, uint64_t _value
		, Units::Enum _units = Units::Kibi
	);

I would like result to look like this:

With aligned arguments (only):

	int32_t prettify(
		  char* _out
		, int32_t _count
		, uint64_t _value
		, Units::Enum _units = Units::Kibi
	);

With aligned parenthesis (only):

	int32_t prettify(
		char* _out
		, int32_t _count
		, uint64_t _value
		, Units::Enum _units = Units::Kibi
		);

Combined:

	int32_t prettify(
		  char* _out
		, int32_t _count
		, uint64_t _value
		, Units::Enum _units = Units::Kibi
		);

Feature Request: support jsx props wrap

Example:

<Component prop1="value1" prop2={3 + 7} prop3={someFunction(someVar)} />

wrap into

<Component 
    prop1="value1"
    prop2={3 + 7}
    prop3={someFunction(someVar)} 
/>

E731: using dictionary as a string

Neovim v0.8.0

I got this when trying to run :ArgWrap:

Error detected while processing function argwrap#toggle[25]..argwrap#extractContainerArgs:
line    1:
E731: using Dictionary as a String
Press ENTER or type command to continue

steps to reproduce:

  1. open new file
  2. type (a, b, c)
  3. run ArgWrap when cursor between ()

Feature Request: List starts on same line

Having an option to make lists start on the same line would be convenient. eg:

void foo(Bar none, Bar one, Bar two);
// becomes
void foo(Bar none,
         Bar one,
         Bar two);

If this already exists then I apologize for not seeing it. Cheers and thanks.

Request: wrap html attributes

<input type="text" class="form-control" id="formGroupExampleInput" placeholder="Example input">

wrap to:

<input
      type="text"
      class="form-control"
      id="formGroupExampleInput"
      placeholder="Example input"
>

Feature request: Move the cursor when expanding/collapsing

Let's say I have the following method:

def foo(hello, world, ohai):
    pass

Now I put my cursor on the first 'h' in 'hello'. After calling ArgWrap the code (as expected) becomes the following:

def foo(
    hello,
    world,
    ohai,
):
    pass

However, my cursor is on the opening parenthesis rather than the 'h' of hello. Now if put my cursor on the 'h' again and call ArgWrap, my cursor stays in the same place in the file and is therefore hovering over 'pass'. Therefore, I can't simply toggle ArgWrap back-and-forth because I have to move my cursor in between the calls.

It'd be great if the cursor tracked the argument that you're hovering over (or at the very least remained within the parenthesis) so that it was easier to toggle between the states.

[Bug Report] Cannot split arguments with odd number of quotes.

Try :ArgWrap this piece of code:

data: {text: 1, anotherText: "it's me", bool: true}

You will find that it stops splitting after the 2nd comma.
My guess is that because the word it's me has odd numbers of single quote inside (From the example, it's just one single quote).

You can try 3 double quotes or 5 single quotes. All of them introduce bugs.
Bugs also occur if the key is a text like this: "it's me"

Work with syntax conceal

Works well without conceal:
image

Not well aligned after conceal
image

Is there a way to calculate the indentation with respect to the length of the concealed characters?

Does not work when the cursor is on the opening bracket

Consider the following line:

[1, 2, 3]

When I have the cursor inside the brackets or on the closing bracket

[1, 2, 3]
        ^

the plugin works correctly:

[
    1,
    2,
    3
]

However, when I have the cursor on the opening bracket

[1, 2, 3]
^

the plugin does nothing. Would it be possible to make the plugin work also when the cursor is on the opening bracket?

Thanks for a very handy plugin BTW!

Screenshot

What's the colorscheme and font name are you using on that screenshot?

Different rules for different type of braces

Plugin is awesome and it works like a charm, however there is one small tweak that probably could make it even more awesome.

If we have this option on:

argwrap_tail_comma=1

We expect braces {} to be like that:

{
    'a',
    'b',
    'c',
}

We expect braces [] to be like that:

[
    'a',
    'b',
    'c',
]

But braces (), to be like that:

(
    'a',
    'b',
    'c'
)

Why?

In python we don't want to generally have this kind of definitions:

def some_function(
    a,
    b,
    c,
)

While it's not syntax and pep8/pylint don't complan about it either it's not widespread used coding standard. I imagine some other languages might be more strict about it.

So I would propose to allow define variable like that:

argwrap_tail_comma={,(,[

To maintain backward compatibility 1 means all types of brackets and 0 none.

Specifying additional characters as argument separators

Would it be possible to have an option that extends which characters are treated as argument separators?

The specific issue that I have is that I often have functions that look like f(a, b, c; d="foo", e="bar") where the semicolon denotes that all the following arguments are keyword arguments (Julia). argwrap is still useful here but the semicolon is not treated as a separator so you'll end up with

f(
  a,
  b,
  c; d="foo",
  e="bar",
)

If there were a way to specify that both , and ; should be treated as argument separators then I'd imagine that we could turn that into

f(
  a,
  b,
  c; 
  d="foo",
  e="bar",
)

By the way - this little plugin is a really nice quality-of-life improvement and I use it many(!) times every day. Thank you!

Feature Request: Support PSR-2 coding standard for opening brace following argument definition

In the PSR-2 coding standard for PHP (and perhaps other coding standards), the position of the opening brace of a method body changes depending on whether the method arguments are single line or multi-line. E.g.

function myFunction($arg1, $arg2, $arg3)
{
   // ...
}
function myFunction(
    $arg1,
    $arg2,
    $arg3
) {
    // ...
}

When toggling with vim-argwrap, the opening brace is not touched, so toggling between single and multi-line takes extra steps to fix the positioning.

It would be great if there were an option that could be enabled that would automatically handle this.

Thanks for the great plugin!

Support delimiters other than comma

In CMakeLists.txt, arguments are just words separated by spaces. These cannot be wrapped cause argwrap plugin looks for comma as delimiter between words.

Can you make the delimiter configurable as a global variable that can be set by the user? User should be able to set it to space or other characters like :.

Conflicting options

Hi there,

Python file looks like this:

foo = ['a', 'b', 'c']

For:

let g:argwrap_tail_comma=0
let g:argwrap_wrap_closing_brace=0

foo = [
    'a',
    'b',
    'c']

For:

let g:argwrap_tail_comma=0
let g:argwrap_wrap_closing_brace=1

foo = [
    'a',
    'b',
    'c'
]

For:

let g:argwrap_tail_comma=1
let g:argwrap_wrap_closing_brace=1

foo = [
    'a',
    'b',
    'c',
]

For:

let g:argwrap_tail_comma=1
let g:argwrap_wrap_closing_brace=0

foo = [
    'a',
    'b',
    'c',

Expected:

foo = [
    'a',
    'b',
    'c',]

[Feature request] Comma first

It would be great if this could have an option to support comma first syntax. An example:

var target =
  { host: this.domain
  , port: this.port
  , path: '/'
  , method: 'GET'
  , agent: false
  , headers: { 'User-Agent': 'Mozilla/5.0' }
  }

We use the above formatting for objects, and ArgWrap will correctly wrap this down to one line, however when wrapping that one line back out to a multi-line object, it defaults to comma last (Example below), having an option to create the object in the above format would be amazing!

var target =
  {
    host: this.domain,
    port: this.port,
    path: '/',
    method: 'GET',
    agent: false,
    headers: { 'User-Agent': 'Mozilla/5.0' }
  }

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.