Skip to content

Explicit imports lens (as seen on Twitter)#310

Merged
alanz merged 5 commits into
haskell:masterfrom
pepeiborra:imports-lens
Aug 15, 2020
Merged

Explicit imports lens (as seen on Twitter)#310
alanz merged 5 commits into
haskell:masterfrom
pepeiborra:imports-lens

Conversation

@pepeiborra

Copy link
Copy Markdown
Collaborator

This adds a new code lens for displaying explicit import lists on import declarations. There is hopefully an animated gif that illustrates it.

@lukel97

lukel97 commented Aug 11, 2020

Copy link
Copy Markdown
Collaborator

Could this be exposed via a source.organizeImports code action instead? This is really handy but I can imagine for modules with a lot of imports you're going to have to be scrolling through a lot of code lenses

@pepeiborra

pepeiborra commented Aug 11, 2020

Copy link
Copy Markdown
Collaborator Author

Could this be exposed via a source.organizeImports code action instead? This is really handy but I can imagine for modules with a lot of imports you're going to have to be scrolling through a lot of code lenses

That would be a completely different feature, a refactoring to rewrite your imports. This plugin is firmly a code lens. Maybe we need to support a way to toggle plugins on/off ?

@ndmitchell

Copy link
Copy Markdown
Collaborator

If you click on the code lens, does it replace your import? Seems like that would be an expected feature, and thus starts to make the two features increasingly similar.

@lukel97

lukel97 commented Aug 11, 2020

Copy link
Copy Markdown
Collaborator

Could this be exposed via a source.organizeImports code action instead? This is really handy but I can imagine for modules with a lot of imports you're going to have to be scrolling through a lot of code lenses

That would be a completely different feature, a refactoring to rewrite your imports. This plugin is firmly a code lens. Maybe we need to support a way to toggle plugins on/off ?

Maybe source.organizeImports is the wrong code action kind, I was thinking more along the lines of a refactoring code action that appears under imports and offers to "Make import list explicit". This was just a thought though, a code lens is also just fine for me

@1Computer1

Copy link
Copy Markdown

I would much prefer a button I can click over code lenses. Rust Analyzer uses code lenses everywhere which gets annoying quick, but they offer a way to disable them while still being able to do the same actions by just hovering over the item which displays actions you can take on it.

@pepeiborra

Copy link
Copy Markdown
Collaborator Author

If you click on the code lens, does it replace your import? Seems like that would be an expected feature, and thus starts to make the two features increasingly similar.

Yes, it does

@pepeiborra

Copy link
Copy Markdown
Collaborator Author

I would much prefer a button I can click over code lenses. Rust Analyzer uses code lenses everywhere which gets annoying quick, but they offer a way to disable them while still being able to do the same actions by just hovering over the item which displays actions you can take on it.

This is a personal preference, I'd rather have a code lens. This is solved with a toggle that you can turn on/off, but currently HLS doesn't provide anything in that regard.

@1Computer1

Copy link
Copy Markdown

Yeah, a toggle would be the best option.

@pepeiborra
pepeiborra requested a review from alanz August 15, 2020 11:49
@alanz
alanz merged commit 23dda97 into haskell:master Aug 15, 2020
@expipiplus1

Copy link
Copy Markdown
Contributor

It might also be nice to disable this for qualified imports.

@pepeiborra

Copy link
Copy Markdown
Collaborator Author

It might also be nice to disable this for qualified imports.

Agreed. Please send a PR if you have the chance!

@expipiplus1

Copy link
Copy Markdown
Contributor

see #354

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants