Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Toggle to enforce a newline at the end of a document #4274

Closed
vdccc opened this issue Oct 14, 2022 · 8 comments · Fixed by #8157
Closed

Toggle to enforce a newline at the end of a document #4274

vdccc opened this issue Oct 14, 2022 · 8 comments · Fixed by #8157
Labels
A-helix-term Area: Helix term improvements C-enhancement Category: Improvements E-easy Call for participation: Experience needed to fix: Easy / not much E-good-first-issue Call for participation: Issues suitable for new contributors

Comments

@vdccc
Copy link

vdccc commented Oct 14, 2022

I suggest adding a toggle eol to enforce a newline at the end of a document.

@vdccc vdccc added the C-enhancement Category: Improvements label Oct 14, 2022
@kuanyinglu
Copy link

I wonder if editorconfig can help enforce it? #279

@the-mikedavis the-mikedavis added the A-helix-term Area: Helix term improvements label Oct 14, 2022
@kirawi kirawi added E-easy Call for participation: Experience needed to fix: Easy / not much E-good-first-issue Call for participation: Issues suitable for new contributors labels Nov 29, 2022
filipdutescu added a commit to filipdutescu/helix that referenced this issue Jan 14, 2023
Add an option (`eof`) to the config which should determine if files
should end with EOF newline character or not. Update documentation of
the book to detail the new flag as well.

Closes: helix-editor#4274
Signed-off-by: Filip Dutescu <[email protected]>
@usagi-flow
Copy link
Contributor

It might be worth mentioning that this is also already unconditionally enforced by rustfmt (:fmt?). So if #279 is implemented/merged, we'd have at least 2 features which enforce this, and this new option would be a third one...

@tosti007
Copy link

this new option would be a third one

I think that there are quite a few cases where such option would provide value, being any where rustfmt or editorconfig isn't available/applicable/redundant.

An example would be editing a simple text file, or a simple script whete I don't want to add an entire editorconfig.

@Boscop
Copy link

Boscop commented Apr 17, 2023

Yes. It would also nice to have a config setting that specifies whether helix should insert a newline at end of file if none exists whenever saving a file (regardless of which language the file is in).

And another config setting to always remove trailing whitespace on save.

Sublime Text has both config settings.

@SuperFluffy
Copy link

Found this because I have the same predicament. Never had the issue in vim, and vscode comes with a config file.insertFinalNewline because they also don't do it by default.

@djpowers
Copy link
Contributor

I think this would be a great addition as well. It looks like there was a pull request linked above that seemed almost ready to merge that has since been closed. Any way that could be reopened to continue the work?

@gabydd
Copy link
Member

gabydd commented May 27, 2023

As it was closed, it's probably better for someone to open a new pr to continue the work. Unless the original author comes back and wants to finish it, but in the meantime it should be ok for someone else to pick it up.

@dvc94ch
Copy link

dvc94ch commented Jun 2, 2023

I think having a .editorconfig in the /home/user directory would be the better or more generic approach.

zqianem added a commit to zqianem/helix that referenced this issue Sep 3, 2023
This resolves helix-editor#4274 with the implementation largely based off of helix-editor#5435
and also addresses the review from @the-mikedavis on that PR.

The option name is from EditorConfig's `insert_final_newline`, which is
also used by VS Code as `files.insertFinalNewline`.

We match Vim's behavior in that :w will add the newline to unmodified
files but :wa will not; see helix-editor#1760.

Co-authored by: Xalfer <[email protected]>
zqianem added a commit to zqianem/helix that referenced this issue Sep 3, 2023
This resolves helix-editor#4274 with the implementation largely based off of helix-editor#5435
and also addresses the review from @the-mikedavis on that PR.

The option name is from EditorConfig's `insert_final_newline`, which is
also used by VS Code as `files.insertFinalNewline`.

We match Vim's behavior in that :w will add the newline to unmodified
files but :wa will not; see helix-editor#1760.

Co-authored-by: Xalfer <[email protected]>
zqianem added a commit to zqianem/helix that referenced this issue Sep 3, 2023
This resolves helix-editor#4274 with the implementation largely based off of helix-editor#5435
and also addresses the review from @the-mikedavis on that PR.

The option name is from EditorConfig's `insert_final_newline`, which is
also used by VS Code as `files.insertFinalNewline`.

We match Vim's behavior in that :w will add the newline to unmodified
files but :wa will not; see helix-editor#1760. Tests are included for this.

Co-authored-by: Xalfer <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-helix-term Area: Helix term improvements C-enhancement Category: Improvements E-easy Call for participation: Experience needed to fix: Easy / not much E-good-first-issue Call for participation: Issues suitable for new contributors
Projects
None yet