You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hemlock's syntax makes hmph's job simple relative to most languages, but there are still a few things a Hemlock code formatter should do to files as a whole:
Replace multi-space/line separation between tokens with single spaces/lines, respectively.
Strip spaces from line ends.
Strip leading/trailing blank lines from each block. In the case of the outermost block this includes stripping \n from the end of the file.
Densely rewrap lines that exceed 100 columns, but make no effort to split tokens which exceed 100 columns even when placed alone on a line.
Additionally, hmph should be capable of operating on ranges of lines rather than whole files. Differences to whole-file mode include:
Leave up to one leading/trailing blank line intact, since there is inadequate context to analyze whether whitespace should be stripped altogether.
Optionally rewrap comments as if they are Markdown-formatted, similarly to bar strings, but with * /# preceding each line rather than |. This must be optional because comments are not required to conform to Markdown formatting.
Naturally, hmph should do minimal (and only recoverable) harm to malformed code. This means at least:
Never drop non-whitespace tokens.
Do not reindent incorrectly indented code, since intent cannot always be determined.
The text was updated successfully, but these errors were encountered:
Bar string syntax is going away, so hmph's job is further simplified. It would be possible to treat strings which are contextually known to be docstrings as Markdown and rewrap, but it's probably best to just leave strings alone.
jasone
changed the title
Implement hmfmt code formatter
Implement hmph code formatter
Feb 25, 2022
Hemlock's syntax makes
hmph
's job simple relative to most languages, but there are still a few things a Hemlock code formatter should do to files as a whole:\n
from the end of the file.Additionally,
hmph
should be capable of operating on ranges of lines rather than whole files. Differences to whole-file mode include:*
/#
preceding each line rather than|
. This must be optional because comments are not required to conform to Markdown formatting.Naturally,
hmph
should do minimal (and only recoverable) harm to malformed code. This means at least:The text was updated successfully, but these errors were encountered: