Skip to content
This repository has been archived by the owner on Dec 13, 2018. It is now read-only.

No settings for Hack code formatter #996

Open
jesseschalken opened this issue Jan 22, 2017 · 9 comments
Open

No settings for Hack code formatter #996

jesseschalken opened this issue Jan 22, 2017 · 9 comments

Comments

@jesseschalken
Copy link
Contributor

There doesn't appear to be any settings for the Hack code formatter. At a minimum I think it should support:

  • Indent type (tabs/spaces)
  • Indent size (number of spaces/size of a tab)
  • Code width (for wrapping, currently stuck at 80 chars)

The double space indent can be changed to a tab with post-processing provided you have no multiline string literals, but there's no workaround for the code width and indent size which influence the wrapping, and 80 chars would be considered too narrow by many teams.

Versions

  • Atom: 1.13.0
  • Nuclide: v0.200.0
  • Client OS: Windows 10
  • Server OS (optional): Ubuntu 16.04.1 LTS
@jesseschalken jesseschalken changed the title Add code width/indent settings setttings for Hack formatter No setttings for Hack formatter Jan 22, 2017
@jesseschalken jesseschalken changed the title No setttings for Hack formatter No setttings for Hack code formatter Jan 22, 2017
@jesseschalken jesseschalken changed the title No setttings for Hack code formatter No settings for Hack code formatter Jan 22, 2017
@fredemmott
Copy link
Contributor

This should probably be filed against HHVM, as this useshh_client --format, which:

  • has no configuration
  • is unsupported (both externally and within FB)

IIRC the plan is to make a complete replacement once @ericlippert's work on the full fidelity parser is complete

@jesseschalken
Copy link
Contributor Author

@fredemmott What does FB use for formatting, then?

@fredemmott
Copy link
Contributor

fredemmott commented Jan 22, 2017

hh_client --format for code that doesn't use recent Hack features (the amount of code this works for is rapidly shrinking), manual for everything else until the new thing is done.

@fredemmott
Copy link
Contributor

fredemmott commented Jan 22, 2017

An FB-free option would be to extend https://github.com/phplang/phack to fully support parsing Hack (as well as the transpilation stuff, it contains an extended nikic/php-parser), then either address phplang/phack#7 or build a separate printer on top of that AST.

The work needed on the parser is pretty much stuff not marked 'Alpha' in the table in Phack's README

@jesseschalken
Copy link
Contributor Author

jesseschalken commented Jan 22, 2017

You would also need to add blank lines (as statements?) to the AST so they are preserved in the output (I think PHP-Parser already has AST nodes for non-doc comments).

@jesseschalken
Copy link
Contributor Author

@fredemmott Does it have options for indent/margin? I couldn't see any in that file.

@fredemmott
Copy link
Contributor

hardcoded - but that's the new thing, so might get fixed :)

AIUI this should be an issue against hack, as it'll still end up talking to the typechecker server; a fix would probalby involve the options going into .hhconfig.

@fredemmott
Copy link
Contributor

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

No branches or pull requests

2 participants