nwolverson/vscode-ide-purescript

Shortcut for apply all import suggestions

dwlizlo opened this issue · 5 comments

We should be able to re-organize imports (apply all import suggestions) by hitting "Organize Imports" shortcut.
At this stage it seems to do nothing which is such a waste :(

Cheers!

"Re-organise imports" is not the same as "apply all import suggestions", to my mind:

  1. "apply all import suggestions" is a code-action which encompasses all the individual import suggestions made on the last build, eg removing import lines or explicit import identifiers which are unused
  2. "organize imports" is a feature that is going to soon be provided by the purescript language server, not yet released with this extension, that will reorder and reformat imports to the compiler standard (but not remove superflous imports etc)

I'm not sure what "it seems to do nothing" means, it sounds like you're talking about an existing '"Organize Imports" shortcut' - could you provide more details of what this is.

Ah, I see there is a standard keybinding for editor.action.organizeImports, which wasn't in the VSCode version I was just running:

CodeActionKind.SourceOrganizeImports identifies an organize imports Code Action. These actions can be triggered using editor.action.organizeImports and have a standard keyboard shortcut: Shift+Alt+O.

We should correctly tag code actions in the language server and it looks like this is pretty much free

(This is work in progress - I started doing this and it is shelved somewhere - will resurrect next time I'm in the vicinity)

Implemented editor.action.organizeImports as a "sort/format imports" and not apply all import suggestions - I think this is more in keeping with other plugins. There is discussion elsewhere about what organize imports should mean, in particular as people set this to be an action on save, it isn't great if it removes unused imports.