VIM / NeoVim

Client Guides

Prerequisites:
  • Neovim 0.11.0 or higher.

  • The phpactor binary is installed and executable in your path

For example: include it in your init.lua:

vim.lsp.enable('phpactor')

Then in ~/.config/nvim/ (or another &runtimepath component) create lsp/phpactor.lua, for example:

return {
    cmd = { 'phpactor', 'language-server' },
    filetypes = { 'php' },
    root_markers = { '.git', 'composer.json', '.phpactor.json', '.phpactor.yml' },
    workspace_required = true,
    init_options = {
        ["language_server_phpstan.enabled"] = false,
        ["language_server_psalm.enabled"] = false,
    }
}

The init_options key maps directly to Phpactors Configuration.

Please refer to the (:help lsp).

See NVIM LSP Configuration Snippets for useful snippets (e.g. reindex, show config, etc).

Troubleshooting

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
}