Introducing Composer.vim
by |Composer.vim provides Vim support for Composer PHP projects.
Features
- A
:Composercommand wrapscomposerwith smart completion of subcommands and flags. It even completes package names from remote package repositories such as packagist.org. Composer.vim doesn’t care what your current working directory is, rather it activates when the current buffer belongs to a Composer project, and Composer.vim has no trouble dealing with multiple Composer projects simultaneously. - Navigate to source files by invoking
<Plug>(composer-find)with the cursor on a class, interface, or trait name. This feature takes advantage of Composer’s autoloader to take you to the right file. The fully-qualified class name will be resolved automatically from the context. No tags file is needed. - Insert a
usestatement for the class, interface, or trait under the cursor by invoking<Plug>(composer-use). Composer.vim can also keep yourusestatements sorted alphabetically, although this feature is currently experimental. - Optional Projectionist support: Invoke
:Ecomposerto edit your project’scomposer.json,:Ato jump tocomposer.lockand back. - Optional Dispatch support:
:Dispatchrunscomposer dump-autoload.
No mappings are provided by default. Here is a sample configuration for your vimrc:
autocmd User Composer nmap <buffer> <LocalLeader>f <Plug>(composer-find) |
\ nmap <buffer> <LocalLeader>u <Plug>(composer-use)
See :help composer for further details.
Installation and Requirements
Using vim-plug, for example:
Plug 'noahfrederick/vim-composer'
Optionally install Dispatch.vim and Projectionist.vim for projections and asynchronous command execution:
Plug 'tpope/vim-dispatch'
Plug 'tpope/vim-projectionist'
Note: either Projectionist.vim or Vim version 7.4.1304 or later is required for JSON support.
Credits and License
Thanks to Tim Pope for Bundler.vim on which Composer.vim is modeled.
Copyright © Noah Frederick. Distributed under the same terms as Vim itself.
See :help license.