Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add option to ignore comments when aligning #46

Closed
zx8 opened this issue Feb 21, 2015 · 7 comments
Closed

Add option to ignore comments when aligning #46

zx8 opened this issue Feb 21, 2015 · 7 comments

Comments

@zx8
Copy link

zx8 commented Feb 21, 2015

Currently when selecting blocks of texts and hitting my AlignTab keybind, if there are any comments, they get aligned along with the actual code.

It'd be great to add an option to "ignore comments" intelligently (e.g. // or # etc. depending on the language) when aligning.

Thanks

@randy3k
Copy link
Owner

randy3k commented Feb 21, 2015

it seems a good idea, but i don't want to complicate the already complicated input...any suggestions?

@zx8
Copy link
Author

zx8 commented Feb 21, 2015

Hm, well, so currently the default settings are:

{
  "named_patterns": {
    "first_equal" : "=/f",
    "first_comma" : ",/f",
    "first_colon" : ":/f",
    "all_and"     : "&",
    "all_bar"     : "\\|",
    "all_space"   : "\\s*/l1l0"
  }
}

Perhaps introduce a new config ignored_patterns which take precedence over all other patterns, and can be configured by language, then leave it up to the users to configure what they want to ignore (e.g. if they want to ignore things that aren't comments, but should never be aligned?). Something like this:

{

  ...

  "ignored_patterns" {
    // Global - applied to all languages
    "*" : [
      "^Do not align me$",
      "^This should(n't| not) be aligned!$"
    ],
    // Python - applied to Python only
    "Python" : [
      "^\s*#.+$"
    ],
    // Perl - applied to Perl only
    "Perl" : [
      "^\s*//.+$
    ]
  }
}

Not quite sure how to approach "multiline ignores" though? Perhaps a separate configuration, or merged into "ignored_patterns":

{

...

  "ignored_patterns_multiline": {
      "Python" : [
        "^\s*'''(.+)'''\s*$"
      ]
    }

}

Thoughts?

@zx8
Copy link
Author

zx8 commented Feb 24, 2015

The above approach is also a potential solution for #45, i.e. one could specify an "ignore pattern" for after: and before: when language=CSS

@randy3k
Copy link
Owner

randy3k commented Feb 24, 2015

i will give it a thought.

@zx8
Copy link
Author

zx8 commented Apr 1, 2015

Hey Randy - any thoughts yet?

@randy3k
Copy link
Owner

randy3k commented Apr 2, 2015

I think your suggestion does make sense. But I will be very busy in the following 2 months and I am afraid that I won't have time to implement it in a short time. A pull request is appreciated.

@zx8
Copy link
Author

zx8 commented May 26, 2015

Hey Randy -- I'd really like to help but I'm also very busy lately.

Still very interested in this feature if anyone else is reading this and fancies putting together a PR.

I'm happy to help test/code review. I just don't have the time to put it together from scratch myself.

[edit] oops, didn't mean to close the issue! re-opened.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants