Skip to content

Implement source.organizeImports code action #719

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

Open
tomjaguarpaw opened this issue Nov 16, 2019 · 4 comments
Open

Implement source.organizeImports code action #719

tomjaguarpaw opened this issue Nov 16, 2019 · 4 comments
Labels

Comments

@tomjaguarpaw
Copy link
Member

I'm using Emacs 26.3 and the lsp-ui install instructions on the ghcide README.

The README says that codeAction (source.organizeImports) is supported. However, if I run lsp-organize-imports I get the error LSP :: source.organizeImports action not available.

image

@cocreature
Copy link
Contributor

Thanks for the report, this is an issue in the readme organizeImports is not (yet) supported. I’ve updated the readme in haskell/ghcide#202 but I’ll keep this issue open as a feature request.

@tomjaguarpaw
Copy link
Member Author

Thanks!

@pepeiborra
Copy link
Collaborator

pepeiborra commented Jan 25, 2020

What would such a code action do? My guess is:

  • It would remove all redundant imports
  • It would fill in all implicit import lists, except for Prelude and hiding decls
  • It would not format, sort or otherwise alter the imports

@jneira jneira transferred this issue from haskell/ghcide Dec 29, 2020
@michaelpj
Copy link
Collaborator

It would not format, sort or otherwise alter the imports

I would expect it to sort the imports. Seems like an organizational issue! Although it's strictly a bit redundant (since presumably the user will format their code separately), there's something psychologically nice about hitting "organize imports" and seeing them become maximally orderly. In Haskell I think that means we ought to format them to deal with things like alignment.

It would fill in all implicit import lists, except for Prelude and hiding decls

If we do this, please let's have an option. At the moment HLS is friendly to those who don't buy the "explicit imports lists everywhere" philosophy - you just don't run the code action that inserts them. It would be nice if organize-imports was also friendly.

@jneira jneira changed the title source.organizeImports action not available Implement source.organizeImports code action Nov 26, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

6 participants