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

make organize imports more flexible about import placement #2100

Open
Techatrix opened this issue Nov 30, 2024 · 1 comment
Open

make organize imports more flexible about import placement #2100

Techatrix opened this issue Nov 30, 2024 · 1 comment
Labels
enhancement New feature or request

Comments

@Techatrix
Copy link
Member

The current implementation of source.organizeImports (#2051) always places the imports at the top of the file. Sometimes you find code that has all imports at the bottom of the file or some imports between code. It would be nice if ZLS could this.

I propose either of these two solutions:

  • add a special case where ZLS will place all imports at the bottom of the file (no config option)
  • never move imports to a different location, only sort imports that are next to each other i.e. not separated by an empty line
@Techatrix Techatrix added the enhancement New feature or request label Nov 30, 2024
@Srekel
Copy link

Srekel commented Dec 31, 2024

+1 to keeping imports together.

Here is an example where it's moved lines from the second "paragraph" of consts into the first paragraph of imports. I like to group imports by having a space inbetween.

image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants