Skip to content
This repository has been archived by the owner on Oct 1, 2020. It is now read-only.

Add syntax highlighting for flow comment types #77

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open

Add syntax highlighting for flow comment types #77

wants to merge 3 commits into from

Conversation

fleischie
Copy link

Hello, I made this PR to allow for "easier" readability of type definitions, when using the flotate/comment type syntax.

I'm up for discussions, whether this is ok or needs expanding of any sort.

Changes:

  • Match comment type include and annotation region.
  • Allow FlowType syntax inside of these regions.
  • Highlight single colon to represent special meaning (kept verbosely in
    type annotation).

Note:

  • When saving the file the first time after opening it will temporarily revert the syntax back to the original one. I suppose this is because [vim-javascript][https://github.com/pangloss/vim-javascript] has a BufWritePost autocommand, that loads the flow syntax items. Reloading the file with :e fixes this.
  • When adding a new line after starting the flow type comment, the comment will be continued. This is because of the formatoptions (the cpo portions of them, to be specific), that I wasn't able to store/restore when adding a new line.
  • When adding a new line after starting the flow type comment, the indentation will be off by one shiftwidth. I don't really understand, where this is coming from.

- Match comment type include and annotation region.
- Allow FlowType syntax inside of these regions.
- Highlight single colon to represent special meaning (kept verbosely in
  type annotation).
@facebook-github-bot
Copy link
Contributor

Thank you for your pull request and welcome to our community. We require contributors to sign our Contributor License Agreement, and we don't seem to have you on file. In order for us to review and merge your code, please sign up at https://code.facebook.com/cla. If you are contributing on behalf of someone else (eg your employer), the individual CLA may not be sufficient and your employer may need the corporate CLA signed.

If you have received this in error or have any questions, please contact us at [email protected]. Thanks!

@facebook-github-bot
Copy link
Contributor

Thank you for signing our Contributor License Agreement. We can now accept your code for this (and any) Facebook open source project. Thanks!

This commit adds support for flow annotations to statements as the
following:
```
function test() /*: $await<number> */ {}
```
Adding `f:/*::` skips comment continuations on new lines, when in a
type annotation comment. This needs to be prepended onto the existing
comments, to remain the behavior of javascript's block comments.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants