adrianlee44 / atom-aligner

Easily align multi-line with support for different operators and custom configurations
https://atom.io/packages/aligner
MIT License
78 stars 3 forks source link

Aligner aligns commas instead of colons with flow #54

Closed glortho closed 8 years ago

glortho commented 8 years ago

When I run aligner (0.21.0) on this flowtype definition to align colons, it aligns commas instead. Is this the expected behavior? If so, how can I align on colons instead?

export type tTopologyNode = {
  active: boolean      , 
  args: Array<string>  , 
  component_id: string , 
  name: string         , 
  prefix: Array<string>, 
  program: string      , 
  pub: string          , 
  sub: string
}
adrianlee44 commented 8 years ago

Thanks for reporting this. What file extension is this saved in and are you using another language package?

adrianlee44 commented 8 years ago

If you are using language-javascript, it seems like the grammar is not parsing : properly here. Going to create a PR on that package to fix this.

adrianlee44 commented 8 years ago

I'm not familiar with flowtype but do you need export here for it to work?

Based on current es6 syntax, https://github.com/ModuleLoader/es6-module-loader/wiki/Brief-Overview-of-ES6-Module-syntax, the first line doesn't seem like valid syntax.

If you remove export, your code block should align properly.

glortho commented 8 years ago

Thanks for the quick response @adrianlee44 . I'm using language-babel. And Flow lets you share types as if they were modules: http://flowtype.org/docs/syntax.html#importing-and-exporting-types . In my case I'm exporting an object type alias, which is common across our codebase.

I know it can be tricky to detect all cases. As a recent convert from vim I was hoping for functionality along the lines of https://github.com/junegunn/vim-easy-align, which lets you specify the character or expression, on the fly or as a keymapping, that you'd like to use as the alignment axis. For example, I also like to align my import statements on the from. I don't suppose you secretly allow for something like that?

adrianlee44 commented 8 years ago

Hi @glortho, if you install language-babel and update aligner to v0.22.0, the code above will align properly.

Let me know if that works.

glortho commented 8 years ago

works! many thanks @adrianlee44