ChristianKohler / NpmIntellisense

Visual Studio Code plugin that autocompletes npm modules in import statements
MIT License
155 stars 43 forks source link

Option to start all imports in the imports list at the start of the file #62

Open dantman opened 5 years ago

dantman commented 5 years ago

I think the NPM Intellisense: Import module command would be more useful if instead of starting at the current cursor location (which may be in the middle of the file where it could be invalid syntax) it would insert the import at the end of the import list at the top of the file.

Bare minimum it would insert it at the top and move the cursor there so you can edit the imported identifiers.

Better would be if it added the import, placed your cursor on the identifier (for ES6 it would be a selection around the {} so you could either replace it with a default identifier import or add names), and if possible placed the equivalent of a snippet's $0 at the original cursor location. That way you could have a workflow like: Command Palette > Import module > Select package > Jump to location > Type out identifiers to import > Tab > Jump back to original cursor > Continue coding

Absolute ideal would be if it added the import and then opened one of the little inline windows vscode uses to peek at other files to the location the import was added at. Then you could edit the imported identifiers without leaving the location you plan to actually use the import.

I've gotten very used to vscode's built-in import feature, I typically type out identifiers and use intellisense to add imports automatically instead of jumping to the start of the file and importing them each time. And I use organize imports / eslint to manage the order of imports so I don't need to bother with that. However there are a few cases like invariant where vscode does not do a good job importing. So it would be really nice if I could use NPM Intellisense: Import module to import those with the same ease.