marlonfan / coc-phpls

🐭 php language server for coc.nvim
MIT License
211 stars 17 forks source link

Is there a way to auto inject use statements in php laravel ? #15

Closed sudkumar closed 5 years ago

sudkumar commented 5 years ago

NOT A BUG

I'm using the plugin and loving it with CoC. I am working on Typescript on frontend and Laravel on backend. While autocompletion works perfectly fine on laravel project, I was just wondering if there is a way to auto inject the use statements which is under the cursor? I don't want to install another plugin (phpactor/phpactor) just to add this feature as this plugin (using Intelephense) correctly suggests the auto completion and namespaces. Please help :).

marlonfan commented 5 years ago

This feature is already available.

sudkumar commented 5 years ago

I'm able to import it using the first method that is shown in the gif but I am not sure how you are adding it in the case of new Order. (I can not see that f in the floating window and I don't know how to use it. :/)

sudkumar commented 5 years ago

Oh... I just found out that, by doing control+f, I can add use statement when I am doing $item = new Item. But I'm not able to add it when Item::staticMethodCall (without assigning to a variable.). Like, is there a way to auto add use statement for the Keyword under the cursor?

sudkumar commented 5 years ago

Okay. I got it. By pressing control+f while in floating window selection mode, I can insert the use statement. Thank you.

rverton commented 4 years ago

Hi, somehow the gif is not viewable anymore. So how do I manually trigger to insert a use statement? When I type the class, I get an autocomplete suggestion for inserting the class. I am looking for the scenario where I am not typing the class name (so no autocompletion), which shortcut can I use to add the import?

Thanks