VIM / NeoVim

Client Guides

Install Phpactor with Global Installation then install CoC:

Plug 'neoclide/coc.nvim', {'branch': 'release'}

Once you have both installed there are two ways of integrating phpactor into coc:

  • Installing the coc phpactor extension:

Restart VIM and type :CocInstall coc-phpactor.

If Phpactor is already installed you can set phpactor.path in :CocConfig to point to the Phpactor binary.

At the root level:

    "phpactor.enable": true,
    "phpactor.path": "/home/vivo/phpactor/bin/phpactor"
  • Without phpactor extension:

Restart VIM and type :CocConfig, you can set up phpactor as a language server for php files directly to coc-settings.json:

"languageserver": {
    "phpactor": {
        "command": "phpactor",
        "args": ["language-server"],
        "trace.server": "verbose",
        "filetypes": ["php"]

I am using the following CoC key bindings and configuration:

" Select range based on AST
nmap <silent><Leader>r <Plug>(coc-range-select)
xmap <silent><Leader>r <Plug>(coc-range-select)

" Navigations
nmap <Leader>o <Plug>(coc-definition)
nmap <Leader>O <Plug>(coc-type-definition)
nmap <Leader>I <Plug>(coc-implementation)
nmap <Leader>R <Plug>(coc-references)

" Hover
nmap K :call <SID>show_documentation()<CR>
inoremap <expr> <cr> pumvisible() ? "\<C-y>" : "\<C-g>u\<CR>"
function! s:show_documentation()
  if (index(['vim','help'], &filetype) >= 0)
    execute 'h '.expand('<cword>')
    call CocAction('doHover')

" Text objects for functions and classes (uses document symbol provider)
xmap if <Plug>(coc-funcobj-i)
omap if <Plug>(coc-funcobj-i)
xmap af <Plug>(coc-funcobj-a)
omap af <Plug>(coc-funcobj-a)
xmap ic <Plug>(coc-classobj-i)
omap ic <Plug>(coc-classobj-i)
xmap ac <Plug>(coc-classobj-a)
omap ac <Plug>(coc-classobj-a)
autocmd CursorHold * silent call CocActionAsync('highlight')

See coc-phpactor for more information.

Install Phpactor with Global Installation then:

Plug 'autozimu/LanguageClient-neovim', {
    \ 'branch': 'next',
    \ 'do': 'bash',
    \ }

And let it know about Phpactor:

let g:LanguageClient_serverCommands = {
    \ 'php': [ 'phpactor', 'server:start', '--stdio']

See the github repository for more details.


Two dollars on variables

This can happen because of the iskeyword setting in VIM.

You can try adding $ to the list of keywords to solve the problem:

autocmd FileType php set iskeyword+=$

or configure Phpactor to trim the $ prefix in .phpactor.json:

    "language_server_completion.trim_leading_dollar": true