marlonfan / coc-phpls

🐭 php language server for coc.nvim
MIT License
212 stars 16 forks source link

auto-import support #37

Open MaxJohnXiang opened 4 years ago

MaxJohnXiang commented 4 years ago

Can this plugin support auto-import packages, just similar to phpStorm.
image

marlonfan commented 4 years ago

Hi, thanks for the feedback.

This feature is not supported for the time being, I will consider integration

joereynolds commented 4 years ago

Hmm, that's odd. This feature exists for me. Whether it's coming from coc-phpls or coc itself, I'm unsure but if I attempt to new a class that isn't already imported into the file, it will show a tilde ~ next to the class name. Pressing <c-y> on the entry will result in the class being imported for use.

image

image

rverton commented 4 years ago

@joereynolds do you know if this behavior is also callable when not in an autocompletion?

For example when my cursor is over the symbol "Car" and I want to import/add a use statement for this class.

joereynolds commented 4 years ago

@rverton,

I've not. Usually I'll start writing new foo to auto import it since you can't do it the way you've suggested. If you do find out, let me know because I would definitely use that functionality

rverton commented 4 years ago

@joereynolds I found something which works (most of the time): Go to the symbol (end of wird), switch to insert mode, press tab (or your completion shortcut), then select the correct line with the use statement you want and press enter. It's not straight forward but works most of the time.

Would appreciate if there will be a hotkey in the future for this.

coc-nvim-phpls

yaegassy commented 4 years ago

@marlonfan @MaxJohnXiang @rverton @joereynolds

Auto-import is available. See: https://github.com/marlonfan/coc-phpls/issues/68

rverton commented 4 years ago

Hi @yaegassy, thanks for the notice. As I understood it's only possible to do this with the payed in intelephense version, is that right?

Thanks