This plugin uses the power of LeaderF to perform PHP namespace related tasks.
- Insert
use
statements for FQCNs. - Sort
use
statements alphabetically. - Expand class names to FQCNs.
- Insert namespace for the current file.
- All the above features support the fuzzy searching function and all the three modes (nameonly, fullpath and regex) provided by LeaderF.
- LeaderF
- ctags is properly configured in Vim/Neovim.
Plug 'xbot/Leaderf-phpnamespace'
" Import the current class under cursor
noremap <leader>iu :<C-U><C-R>=printf("Leaderf phpns --input %s", expand("<cword>"))<CR><CR>
" Expand the classname under cursor to its FQCN form.
noremap <leader>ec :<C-U><C-R>=printf("Leaderf phpns --input %s --expand", expand("<cword>"))<CR><CR>
Command | Description |
---|---|
LeaderfPhpns | Choose an FQCN to import. |
PHPNamespaceInsert | Insert namespace for the current file. |
Press F1
to get more help
Option | Default | Description |
---|---|---|
g:Lf_PHPNamespaceExpandToAbsolute | 1 | Expand the classname under cursor to absolute FQCN. |
g:Lf_PHPNamespaceSortAfterImport | 1 | Sort the use statements block alphabetically after importing a class. |
MIT