Git Product home page Git Product logo

better-align's People

Contributors

warwithinme 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

Watchers

 avatar  avatar  avatar  avatar  avatar

better-align's Issues

Customizable symbol list

I'd like to also align additional symbols such as ::, ., ->, <-, etc. It probably doesn't make sense to keep extending this plugin with every possible symbol, but it might be feasible to allow both global and per-language symbol customization. Something like:

"alignment.symbols": {
  "global": [ "..." ],
  "purescript": [ "=", "==", "/=", "::", ".", "->", "<-" ]
}

'fi' in the name of variable break alignment

Before:

num_of_azs . =    "${var.num_of_azs}"
cidr =  "${var.cidr}"
private_subnet_suffix    =    "${var.private_subnet_suffix}"
private_subnets      =     "${var.private_subnets}"

After:

num_of_azs             = "${var.num_of_azs}"
cidr                   = "${var.cidr}"
private_subnet_suffix = "${var.private_subnet_suffix}"
private_subnets        = "${var.private_subnets}"

Can we add support for ' => ' ?

I use php and when i need to align an array declaration:

$data = array(
    'text' => 'something',
    'here is another' => 'sample'
);

Gets converted to:

$data = array(
        'text'            = > 'something',
        'here is another' = > 'sample'
);

It does the alignment beautifully! But changes => to = > (space added) and breaks the code.

There is a problem with ===

There is a problem with the syntax of JavaScript. For '===', the plugin will format it as '= ==', which is obviously not what we want, which will cause a syntax error.

can it also align imports?

It would be really nice if this could also align imports:

from:

import React, { Component } from 'react';
import autoBind from 'react-autobind';
import PropTypes from 'prop-types';
import { List } from 'immutable';
import cx from 'classnames';

To:

import React, { Component } from 'react';
import autoBind             from 'react-autobind';
import PropTypes            from 'prop-types';
import { List }             from 'immutable';
import cx                   from 'classnames';

Error in vue

In vue ":(v-bind:)" automatically adds a space after itI
image

Ignore tags that will force/tell to an extension to skip part of the code

Since extension sometimes breaks something or we don't want something to align for some reason it would be awesome to introduce "ignore" tags:

... code that can be aligned
... code that can be aligned
... code that can be aligned

// @better-align-disable

... code that must not be aligned !

// @better-align-enable

... code that can be aligned
... code that can be aligned
... code that can be aligned

Thank you for a great extension!

Variables align with array elements

Really like the extension and how easy it is to configure but I'm having an issue with variables being aligned with array elements.

For example, aligning this code:
image

Gives me:
image

Notice how $q is being aligned with the 'players' array element?

What I'd like to see is:
image

Is this possible via a config option?

ES6 import support

Is there any way to make it align ES6 imports?
eg:

import React from 'react'
import ReactNative from 'react-native'
import styleSheet from './section.style'
import SectionRow from './section-row'

=>

import React       from 'react'
import ReactNative from 'react-native'
import styleSheet  from './section.style'
import SectionRow  from './section-row'

[BUG] Align adds unnecessary leading space every time.

Align this code.

           articlesSubject$: Subject<Article[]>;
           articles$       : Observable<Article[]>; // Final Observable
  readonly nextFunc        : (value: Article[]) => void = v => this.articlesSubject$.next(v);

Gives.

                    articlesSubject$: Subject<Article[]>;
                    articles$       : Observable<Article[]>;                                            // Final Observable
           readonly nextFunc        : (value: Article[]) => void = v => this.articlesSubject$.next(v);

Align again.

                             articlesSubject$: Subject<Article[]>;
                             articles$       : Observable<Article[]>;                                            // Final Observable
                    readonly nextFunc        : (value: Article[]) => void = v => this.articlesSubject$.next(v);

This aligns normally.

           articlesSubject$: Subject<Article[]>;
           articles$       : Observable<Article[]>;  // Final Observable
  readonly nextFunc = v => this.articlesSubject$.next(v);

Only "Visually" Aligned Support?

Is there any chance that we can add support for "visually" alignment? By that I mean no spaces should be added to the code itself but the IDE appears these spaces to make it aligned.

If so, there's no need to worry about eslint errors or collaboration conflicts, etc.

Or, we could add a setting to only commit the unaligned code in Git but when come back to IDE, make it better-aligned?

Better ideas?

[Feature Request] Align wrapped lines

OMG! This extension is the best! 👏👏👏

It would be very useful to align long lines which are wrapped.

Example:
VSCode current format (simple indentation):

return veryLongThing1() && veryLongThing2()
  || someOtherThing1() && someOtherThing2();
somePromise.then(doSomething)
    .then(doSomethingElse)
    .catch(handleError);

Better Align would look like:

return veryLongThing1()  && veryLongThing2() // Space padding before `&&`
    || someOtherThing1() && someOtherThing2(); // First expression aligned to first expression on first line 
// Aligned dots for function chaining
somePromise.then(doSomething)
           .then(doSomethingElse)
           .catch(handleError);

Cheers and happy coding 🥂

support #define and functions in the header file in C/C++

could you please support #define and functions in the header file like:

// Original code
#define DEFINE_1 DEFINE
#define ANOTHER_DEFINE_1 DEFINE_1

// after use align
#define DEFINE_1         DEFINE
#define ANOTHER_DEFINE_1 DEFINE_1

in functions

// Original code
int firstFunctions();
unsigned int secondFunctions();
void thirstFunction();

// after use align
int          firstFunctions();
unsigned int secondFunctions();
void         thirstFunction();

+= is replaced with =

on v 1.1.3, when aligning the following line:
result += 'Some text'
it gets replaced with
result = 'Some text'
Note the missing +.

Is it possible to disable alignment for some token?

I'd like to disable alignment by colon ":" for erlang files
See my snippets below

If I align this

            {ok, Pid} = supervisor:start_child(Sup, Args),
            NewRef = erlang:monitor(process, Pid),
            NewRefs = gb_sets:insert(NewRef, gb_sets:delete(Ref, Refs)),
            gen_server:reply(From, {ok, Pid}), % <---- See there is no "=" sign

Then I get

            {ok, Pid} = supervisor: start_child(Sup, Args),
            NewRef    = erlang    : monitor(process, Pid),
            NewRefs   = gb_sets   : insert(NewRef, gb_sets:delete(Ref, Refs)),
                      gen_server  : reply(From, {ok, Pid}),                    % <---- See there is no "=" sign```

But I want this:

            {ok, Pid} = supervisor:start_child(Sup, Args),
            NewRef    = erlang:monitor(process, Pid),
            NewRefs   = gb_sets:insert(NewRef, gb_sets:delete(Ref, Refs)),
            gen_server:reply(From, {ok, Pid}),                    % <---- See there is no "=" sign

Could you please add a configurations keys for tokens which may be aligned by?
Thank you in advance

Can't get it to work

I'm really sorry and honestly am feeling dumb, but I can't get it to work.

Is there any dependency I need to get it to work under OSX?

Screencast of what it does

Using Visual Studio Code 1.17.2 under MacOS X Sierra 10.12.6

Alignment of comments.

How can i align only comments?Editing the option "comment" : spaces, doesn't help for proper alignment of comments.

Ignore files

Is there a configuration to exclude some files. For example, I don't want package.json to be aligned automatically.

Thanks
Anand

multiple function aligment

I noticed that it doesn't recognize .func() for alignment for example:
taking this

return gulp.src(jsFiles)
    .pipe(plumber())
    .pipe(sourcemaps.init())
		    .pipe(concat('bundle.js'))
    .pipe(sourcemaps.write('.'))
    .pipe(gulp.dest('./content'));

and making it

return gulp.src(jsFiles)
    .pipe(plumber())
    .pipe(sourcemaps.init())
    .pipe(concat('bundle.js'))
    .pipe(sourcemaps.write('.'))
    .pipe(gulp.dest('./content'));

I am not sure how difficult this would as I have never worked with the language you are using.

Warning in toggle 'alignment.beforeSave'

Environment

OSX: 10.11.2
VSCode: 1.16.1
Better Align: 1.1.10

Configuration

In settings.json

"alignment.beforeSave": true

Problem

This works, but somehow shows incorrect boolean
2017-09-16_13-08-46

is:issue is:open splits `==` to `= =`

I use Haskell where == is the comparation operator; it must not be split into = = by align.
The tool would be helpful, especially to make list re-aligned with leading ,.

Bash not aligned properly

The current formatting rules will break bash scripts (sh, bash, zsh, etc)

Start with

export XDG_CONFIG_HOME="${HOME}/.config"
export XDG_CACHE_HOME="${HOME}/.cache"
export XDG_DATA_HOME="${HOME}/.local/share"
export XDG_RUNTIME_DIR="$XDG_CACHE_HOME"
export ZPLUG_HOME="${HOME}/.zplug"
export ZSH_DIR="${XDG_CONFIG_HOME}/zsh"

Expectation

export XDG_CONFIG_HOME="${HOME}/.config"
export  XDG_CACHE_HOME="${HOME}/.cache"
export   XDG_DATA_HOME="${HOME}/.local/share"
export XDG_RUNTIME_DIR="$XDG_CACHE_HOME"
export      ZPLUG_HOME="${HOME}/.zplug"
export         ZSH_DIR="${XDG_CONFIG_HOME}/zsh"

Actual

export XDG_CONFIG_HOME = "${HOME}/.config"
export XDG_CACHE_HOME  = "${HOME}/.cache"
export XDG_DATA_HOME   = "${HOME}/.local/share"
export XDG_RUNTIME_DIR = "$XDG_CACHE_HOME"
export ZPLUG_HOME      = "${HOME}/.zplug"
export ZSH_DIR         = "${XDG_CONFIG_HOME}/zsh"

Reason

Spaces around the = in most any shell script will break the assignment, alias, export, and others. They should be aligned on the = but have no spaces around them. Instead, the spaces should be inserted before the left hand side.

c++ vertically declaration alignment

Can you add vertically declaration alignment? E.g. this code
default
must be converted to this:
default
And can I remove colon(:) from the operators to the padding, because this code:
default
becomes broken:
default

command 'wwm.aligncode' not found

Installed this extension and added the shortcut:

{ "key": "ctrl+cmd+=", "command": "wwm.aligncode",
"when": "editorTextFocus && !editorReadonly" }

Align by Value?

Is there any way to make this align javascript objects by value instead of by colon? The plugin currently takes an object and does this:

{
    a: 'a',
    asdf: 'sldfk',
    klj: 'lksjdlk',
}

=>

{
    a   : 'a',
    asdf: 'sldfk',
    klj : 'lksjdlk',
}

But I would rather it keep the colon next to the key and align the vlaues, like this:

{
    a:    'a',
    asdf: 'sldfk',
    klj:  'lksjdlk',
}

Is there a built in setting that would allow this to be configured?

Issues aligning with nested arrays

It doesn't seem to work with nested arrays. In the example below the first part of the array (all the way to the key "wrapper"), is aligned correctly. But it doesn't align anything below the "wrapper" key. So when I give the command to align the bottom part (after "wrapper"), it aligns it but it ignores the top part spacing, and does its own spacing. So I ended up with one array where the first section is aligned to a certain amount of spacing and the second part to another. This seems to happen anytime it finds a nested array.

What's happening:

screen-shot-2017-12-07-at-9 19 38-am

What's expected:
screen shot 2017-12-07 at 9 26 08 am

Support for tab

Hi @WarWithinMe, thanks for the plugin! The plugin currently uses space to align. This throws up errors with eslint etc, if you are using tabs in your project elsewhere. In those cases, even just for consistency, one would like to use tabs to align.

Do you think the plugin could support an option for spaces vs tabs?

Ternary statements in objects effected

v 1.1.6

I am having an issue where the colon of ternary statements are being effected as well when aligning properties of an object. Please see the screenshot below for the results of my values after using the align command.

screen shot 2017-10-13 at 11 26 13 am

The false values are pushed so far right because of longer property values set above the screenshot.

Comments not aligning in Python

When writing Python code (indentation set at 4 spaces)...

Aligning this:

var1 = 123  # first var
var999 = 99981    # bigger var

Produces this:

var1   = 123  # first var
var999 = 99981    # bigger var

But I'd like this:

var1   = 123      # first var
var999 = 99981    # bigger var

[Feature request] Support for leading open parenthesis

If I have the following (Ruby) code:

do_the_thing(on: me,
  with: it,
  using: flamethrower,
ignoring: nil)

and I invoke Align on the with: it line, the result is:

do_the_thing(on: me,
  with:     it,
  using:    flamethrower,
  ignoring: nil)

It would be great if it could align all the arguments, including the one on the line with the open-paren, to produce the following:

do_the_thing(on:       me,
             with:     it,
             using:    flamethrower,
             ignoring: nil)

It breaks "==" in python string block

pGetTFs = proc()
pGetTFs.input = "cedir:file"
pGetTFs.output = "outfile:file:{{cedir | fn}}.tfs.txt"
pGetTFs.script = """
awk '({{genes | map(lambda x: '$4 == "'+x+'"' , _) | " || ".join(_)}})  {print $2}' {{cedir}}  /*.coexp.txt | sort | uniq > "{{outfile}}"
#                                 ^^
"""

After alignment:

pGetTFs        = proc()
pGetTFs.input  = "cedir:file"
pGetTFs.output = "outfile:file:{{cedir | fn}}.tfs.txt"
pGetTFs.script = """
awk '({{genes | map(lambda x: '$4 = = "'+x+'"' , _) | " || ".join(_)}})  {print $2}' {{cedir}}  /*.coexp.txt | sort | uniq > "{{outfile}}"
#                                 ^^^
"""

A possible solution is to detect whether there is a = right after =. In most cases, double = means equality check instead of assignment.

Unexpected indent in R language

Original code

alist = list(a=1,b=2)
alist[["a"]] = 3
alist$b = 4

After align:

      alist   = list(a=1,b=2)
alist[["a"]]  = 3
      alist$b = 4

Expected:

alist         = list(a=1,b=2)
alist[["a"]]  = 3
alist$b       = 4

All options are left as default.

VBS support

Nice shot.

I wish I could use it with other languages like VBS. For instance, I can not align this VBS code block:

Dim fAnime : fAnime = 0			' Remove Bracket and its content "[Hyogo]_Naruto_Shippuuden_143_VOSTFR_[400p]_[Xvid-Mp3]_[FADDA119](1280x720x264AAC)" will results "Naruto_Shippuuden_143_VOSTFR"
Dim fBracket : fBracket = 0		' Replace "[]" with "()"
Dim fBrakSpace : fBrakSpace = 1	' Put a space around brackets
Dim fComSpace : fComSpace = 1	' Put a space after comma
Dim fDot : fDot = 1				' Dots to spaces except for numbers & extension
Dim fExtLCase : fExtLCase = 1	' Make extension lower case
Dim fManga : fManga = 0			' Add "0" before volume and chapter, i.e.: "Kenichi - v2 - c8 - 01.jpg" to "Kenichi - v02 - c08 - 01.jpg"

like this:

Dim fAnime     : fAnime     = 0  ' Remove Bracket and its content "[Hyogo]_Naruto_Shippuuden_143_VOSTFR_[400p]_[Xvid-Mp3]_[FADDA119](1280x720x264AAC)" will results "Naruto_Shippuuden_143_VOSTFR"
Dim fBracket   : fBracket   = 0  ' Replace "[]" with "()"
Dim fBrakSpace : fBrakSpace = 1  ' Put a space around brackets
Dim fComSpace  : fComSpace  = 1  ' Put a space after comma
Dim fDot       : fDot       = 1  ' Dots to spaces except for numbers & extension
Dim fExtLCase  : fExtLCase  = 1  ' Make extension lower case
Dim fManga     : fManga     = 0  ' Add "0" before volume and chapter, i.e.: "Kenichi - v2 - c8 - 01.jpg" to "Kenichi - v02 - c08 - 01.jpg"

Regards

Command 'wwm.aligncode' not found

Environment

OSX: 10.11.2
VSCode: 1.16.1
Better Align: 1.1.10

Configuration

In keybindings.json

{ "key": "cmd+2",  "command": "wwm.aligncode", "when": "editorTextFocus && !editorReadonly" },

Problem

2017-09-16_12-53-17

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.