I want to use both Intelephense and Phpactor with the Neovim LSP because Phpactor seems to be better in code refactoring. But within my WordPress plugins code I get messages like Function "register_activation_hook" not found
for all WordPress functions. The WordPress installation lives in `/var/www/dev.
Where is my configuration problem?
local capabilities = vim.lsp.protocol.make_client_capabilities()
capabilities = require( "cmp_nvim_lsp" ).default_capabilities( capabilities )
lspconfig.intelephense.setup( {
capabilities = capabilities,
settings = {
intelephense = {
files = {
maxSize = 5000000, -- Increase max file size if needed
associations = { "**/*.php", "**/wp-includes/**/*.php", "**/wp-admin/**/*.php" }, -- Explicitly include WordPress files
exclude = { "**/node_modules/**", "**/vendor/**", "**/.git/**" },
},
environment = {
includePaths = { "/var/www/dev/wp-includes", "/var/www/dev/wp-admin" }, -- Set to your WordPress installation
},
stubs = {
"wordpress", "wordpress-globals", "wp-cli", "woocommerce", "acf-pro",
"bcmath", "bz2", "calendar", "Core", "curl", "date", "dom", "genesis", "json", "libxml", "mbstring", "openssl",
"pcre", "reflection", "session", "simplexml", "sodium", "spl", "standard", "xml", "zlib", "zip",
},
diagnostics = {
enable = true,
},
completion = {
fullyQualifyGlobalConstants = true,
insertUseDeclaration = true,
},
},
},
} )
lspconfig.phpactor.setup( {
capabilities = capabilities,
init_options = {
["language_server_phpstan.enabled"] = false, -- Disable PHPStan analysis if not need
ed
["language_server_psalm.enabled"] = false, -- Disable Psalm if not used
},
handlers = {
["textDocument/completion"] = function() end, -- Disable Phpactor completion (use In
telephense)
["textDocument/hover"] = function() end, -- Disable Phpactor hover (use Intelep
hense)
["textDocument/definition"] = function() end, -- Disable go-to-definition in Phpacto
r
["textDocument/references"] = function() end, -- Disable references (use Intelephens
e)
["textDocument/documentSymbol"] = function() end, -- Disable symbol indexing (use In
telephense)
["workspace/symbol"] = function() end, -- Prevent Phpactor from taking over workspac
e symbols
},
} )