Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- "ftplugins/php.vim
- function! s:createSnippet(line)
- let l:signature = matchstr(a:line, '\v\s+[a-z0-9A-Z_]+\s*\(.*\)')
- let l:methodName = substitute(substitute(l:signature, '(.*$', '', 'g'), '\s', '', 'g')
- let l:paramList = []
- let l:params = substitute(l:signature, '\$[a-zA-Z0-9_]\+', '\=add(l:paramList, submatch(0))', 'g')
- let l:templateParams = []
- for p in l:paramList
- let l:parameterPos = len(l:templateParams) + 1
- call add(l:templateParams, '${' . l:parameterPos . ':' . p . '}')
- endfor
- if l:methodName !=# '__construct'
- let l:template = l:methodName . '(' . join(l:templateParams, ', ') . ')$0'
- else
- let l:template = '(' . join(l:templateParams, ', ') . ')$0'
- endif
- execute "normal! a\<C-r>=UltiSnips#Anon('" . l:template . "')\<cr>"
- endfunction
- function! s:fzfphpmethods()
- call fzf#run({
- \ 'source': "ag -a --php --vimgrep '(public)? +(function\|@method) (.+) *\\(.*\\)'",
- \ 'sink': function('s:createsnippet'),
- \ 'down': '30%'
- \})
- endfunction
- command! -buffer PhpMethods call <sid>fzfPhpMethods()
- inoremap <buffer> <C-l> <esc>:PhpMethods<CR>
Add Comment
Please, Sign In to add comment