neoclide / coc-tsserver

Tsserver extension for coc.nvim that provide rich features like VSCode for javascript & typescript
MIT License
1.05k stars 68 forks source link

Feature request: import suggestion only for current cursor #282

Closed lo1tuma closed 3 years ago

lo1tuma commented 3 years ago

Hi, I’ve switched from nvim-typescript to coc recently and so far I’m quite happy but I’m missing one feature. I don’t really like auto imports, since they are quite often wrong in bigger projects. nvim-typescript provided a command :TSImport which suggested several possible imports for the identifier under the current cursor where you could then choose which one should be added to import statements of the current file. If there was only one suggestion, then the step of choosing something was skipped and the import statement was added directly.

Currently I have disable auto imports and add a :OR command which just runs organizeImports. Unfortunately this command also tries to import things for every unresolved identifier, even for still work-in-progress code that I want to change in the next minute. Additionally it seems like it sorts my existing import statements alphabetically, which is an undesired change for me.

fannheyward commented 3 years ago

Does code action work for you? Put your cursor on unresolved identifier and fire <Plug>(coc-codeaction-cursor), coc will list available imports.

截屏2021-04-14 下午5 08 40
chemzqm commented 3 years ago

You have to use codeActions

lo1tuma commented 3 years ago

Nice, I wasn’t aware of that feature. Thank you.