🌚

Leaderf-phpnamespace: Yet another PHP namespace resolver

Posted at — Sep 25, 2022
#Vim #LeaderF #plugin #编程

This plugin uses the power of LeaderF to perform PHP namespace related tasks.

https://github.com/xbot/Leaderf-phpnamespace

Features

Requirements

Install

Use any of your favourite plugin manager to install it, for example:

vim-plug

1
Plug 'xbot/Leaderf-phpnamespace'

Setup

1
2
3
4
5
" 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>

Commands

CommandDescription
LeaderfPhpnsChoose an FQCN to import.
PHPNamespaceInsertInsert namespace for the current file.

Press F1 in the popup window to get more help.

Options

OptionDefaultDescription
g:Lf_PHPNamespaceExpandToAbsolute1Expand the classname under cursor to absolute FQCN.
g:Lf_PHPNamespaceSortAfterImport1Sort the use statements block alphabetically after importing a class.