Awesome
Php Easy NVim
A few functions for make work with PHP 7.4 (or more) projects easy and quickly.
Install
With lazy.nvim:
{
'ta-tikoma/php.easy.nvim',
config = true,
keys = {
{'-b', '<CMD>PHPEasyDocBlock<CR>'},
{'-r', '<CMD>PHPEasyReplica<CR>'},
{'-c', '<CMD>PHPEasyCopy<CR>'},
{'-d', '<CMD>PHPEasyDelete<CR>'},
{'-uu', '<CMD>PHPEasyRemoveUnusedUses<CR>'},
{'-e', '<CMD>PHPEasyExtends<CR>'},
{'-i', '<CMD>PHPEasyImplements<CR>'},
{'-ii', '<CMD>PHPEasyInitInterface<CR>'},
{'-ic', '<CMD>PHPEasyInitClass<CR>'},
{'-iac', '<CMD>PHPEasyInitAbstractClass<CR>'},
{'-it', '<CMD>PHPEasyInitTrait<CR>'},
{'-ie', '<CMD>PHPEasyInitEnum<CR>'},
{'-c', '<CMD>PHPEasyAppendConstant<CR>', mode = {'n', 'v'}},
{'-p', '<CMD>PHPEasyAppendProperty<CR>', mode = {'n', 'v'}},
{'-m', '<CMD>PHPEasyAppendMethod<CR>', mode = {'n', 'v'}},
{'-_', '<CMD>PHPEasyAppendConstruct<CR>'},
{'-a', '<CMD>PHPEasyAppendArgument<CR>'},
}
},
Features
Example Key Binding | Function | Description |
---|---|---|
Any | function or property or constant | |
-y | PHPEasyCopy | Yank (copy) any under cursor |
-r | PHPEasyReplica | Replica any: Copy under cursor, paste after current and trigger rename function |
-d | PHPEasyDelete | Delete any under cursor |
-b | PHPEasyDocBlock | PhpDocBlock for any or class or variable |
Append | ||
-c | PHPEasyAppendConstant | Append constant |
-p | PHPEasyAppendProperty | Append property |
-m | PHPEasyAppendMethod | Append method |
-_ | PHPEasyAppendConstruct | Append __construct |
-a | PHPEasyAppendArgument | Append new argument in current function |
Objects | ||
-uu | PHPEasyRemoveUnusedUses | Remove unused uses from current class |
-e | PHPEasyExtends | Extends current class |
-i | PHPEasyImplements | Implements current class |
-ic | PHPEasyInitClass | Initialize class in current file |
-iac | PHPEasyInitAbstractClass | Initialize abstract class in current file |
-ii | PHPEasyInitInterface | Initialize interface in current file |
-it | PHPEasyInitTrait | Initialize trait in current file |
-ie | PHPEasyInitEnum | Initialize enum in current file |
Configuration
{
regex = { -- regex for parse php file
tab = ' ',
startTab = '^' .. tab,
visibility = startTab .. '\\(public\\|protected\\|private\\|\\)\\s\\{1}',
static = '\\(static\\s\\|\\)',
constant = visibility .. 'const ',
property = visibility .. static .. '\\(?*\\w\\+\\s\\|\\)\\$',
method = visibility .. static .. 'function',
construct = method .. ' __construct(',
methodEnd = startTab .. '}',
comment = startTab .. '\\/',
commentMiddle = startTab .. '\\*',
commentEnd = startTab .. '\\s\\*',
any = startTab .. '[p}]\\{1}',
variable = '\\(' .. tab .. '\\)\\+\\$\\w\\+\\s\\{1}=\\s\\{1}',
object = '^\\(final class\\|abstract class\\|class\\|interface\\|trait\\|enum\\)\\s\\{1}',
},
onSave = { -- on save php file action
removeUnusedUses = true -- remove unused uses (then use lsp: intelephense)
},
onAppend = { -- on append entity
engine = 'defalut' -- how to insert template. 'default' - just string, 'LuaSinp' - via 'L3MON4D3/LuaSnip'
}
}