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

Add function to format region/file #8

Closed
4 of 6 tasks
lucaswerkmeister opened this issue May 11, 2017 · 0 comments
Closed
4 of 6 tasks

Add function to format region/file #8

lucaswerkmeister opened this issue May 11, 2017 · 0 comments
Milestone

Comments

@lucaswerkmeister
Copy link
Owner

lucaswerkmeister commented May 11, 2017

Pipe it through ceylon format --pipe.

If ceylon format isn’t available, it’s probably better to just bail out rather than install one version from ceylon-mode, otherwise an outdated ceylon-mode will install old ceylon.formatter versions.

@lucaswerkmeister lucaswerkmeister added this to the 1.0 milestone May 11, 2017
lucaswerkmeister added a commit that referenced this issue May 13, 2017
Part of #8.

Error handling isn’t great (I managed to move the error output to a
separate buffer, but it still replaces the region with stdout, which in
case of error is empty), but a fix for that will probably be a bit
involved.

There are also numerous improvements to be made: fall back to entire
buffer if there is no region (the other part of #8); strip the trailing
newline if it wasn’t there in the original code; adjust indentation
(probably just copy the indentation of the beginning of the region and
prepend it to all following lines).
lucaswerkmeister added a commit that referenced this issue May 13, 2017
lucaswerkmeister added a commit that referenced this issue May 13, 2017
lucaswerkmeister added a commit that referenced this issue May 13, 2017
The initial indentation of the first line can be partially within the
region and partially outside of it. For example, suppose the first line
is indented by four spaces, and the region begins with the second space
(region-beginning is between the first and second space). The
indentation that must be added to all lines after the first one is four
spaces, but for the first line, one space was outside the region and was
therefore not removed by ceylon.formatter, so only three spaces need to
be added to that line.

Part of #8.
lucaswerkmeister added a commit that referenced this issue May 13, 2017
And also ceylon-format-region-or-buffer, which formats either the region
or the buffer and is the new keybinding for formatting.

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

No branches or pull requests

1 participant