I've already spent two days trying to make a good work environment with VIM for a framework, in this case, laravel.
All is perfect as always, but there is a very important issue:
I've tried all that I found via google:
-phpcomplete: despite in other of my projects works well, it seems that gets mad with composer. Doesn't recognize facades nor common methods for the framework.
-ctags: helps with some methods, but still a mess with omnicompletion.
-phpcomplete-extended and phpcomplete-extended for laravel: author doesn't maintain this plugin anymore (logical since frameworks change so quick) so does not work anymore.
-PIV, uses standart phpcomplete, so same issue.
-padawan.php I couldn't get it to work, IMHO poorly documented
Is there any vim user who could manage to get omnicompletion functionality properly? I'm starting to think I should move from vim since it's not ready for these new technologies :'(
Grep AppServiceProvider
against tags
file:
AppServiceProvider app/Providers/AppServiceProvider.php /^class AppServiceProvider extends ServiceProvider$/;" c namespace:Furbook\Providers Furbook\Providers app/Providers/AppServiceProvider.php /^namespace Furbook\Providers;$/;" n boot app/Providers/AppServiceProvider.php /^ public function boot()$/;" f class:Furbook\Providers::AppServiceProvider register app/Providers/AppServiceProvider.php /^ public function register()$/;" f class:Furbook\Providers::AppServiceProvider
This has been one of my top concerns, here are my preferred options:
Phpactor. My current choice, works pretty well and it's main dev is really active. Fast and has A LOT of refactoring tools. Great for composer projects.
ctags
I use phpcomplete and ctags (patched for php), but still no autocompletion for facades, I resolved this with the Laravel 5 IDE Helper Generator. The idea is to generate a _ide_helper.php
file with classes and methods for facades first, and then create the tags.
I also created a function in my vimrc, so I can automatically generate the tags.
function! GenTags()
if isdirectory("./vendor")
echo '(re)Generating framework tags'
execute "!php artisan ide-helper:generate"
echo '(re)Generating tags'
execute "!ctags -R --filter-terminator=php"
else
echo 'Not in a framework project'
if filereadable("tags")
echo "Regenerating tags..."
execute "!ctags -R --filter-terminator=php"
else
let choice = confirm("Create tags?", "&Yes\n&No", 2)
if choice == 1
echo "Generating tags..."
execute "!ctags -R --filter-terminator=php"
endif
endif
endif
:endfunction
command! -nargs=* GenTags call GenTags()
GenTags()
-- install eclipse, don't use eclipse installer, better untar directly
-- install eclim, use the eclim installer.
-- For complete code completion change your models to extend Eloquent
instead of Model
-- and the plugin YouCompleteMe (you can try any other)
Despite autocompletion is still a bit worse than eclipse (eclim), the Php Language server is developed on PHP, which means a lot of PHP users can contribute to the project and it's pretty active and improving.
Plug 'roxma/nvim-completion-manager'
" (optional) javascript
Plug 'roxma/nvim-cm-tern', {'do': 'npm install'} "
"(optional) language server protocol framework
Plug 'autozimu/LanguageClient-neovim', { 'do': ':UpdateRemotePlugins' } "
"(optional) php completion via LanguageClient-neovim
Plug 'roxma/LanguageServer-php-neovim', {'do': 'composer install && composer run-script parse-stubs'}
If anyone wants to know more can check my vimrc at github
Talking about padawan.php that's true about documentation, I haven't spent enough time to make it more or less useful, but installation of padawan shouldn't be that hard:
composer global require mkusher/padawan
I'm not sure whether Laravel projects will work out of the box or you still will need ide helper, but general php things should work well.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With