I was not able to find how to configure lspconfig to set the file.associations structure for php files that drupal uses.
In here: nvim-lspconfig/server_configurations.md at master · neovim/nvim-lspconfig · GitHub
There is an example of setting filetypes.
filetypes = { "php" }
In here: GitHub - bmewburn/vscode-intelephense: PHP intellisense for Visual Studio Code They mention what the structure might look like:
"files.associations": { "*.module": "php" }
So for drupal development, inside my nvim-lspconfig.lua I think I would want something like this
local files_associations = {}
files_associations["*.install"] = "php"
files_associations["*.theme"] = "php"
files_associations["*.module"] = "php"
files_associations["*.inc"] = "php"
for _, lsp in ipairs(servers) do
nvim_lsp[lsp].setup {
on_attach = on_attach,
capabilities = capabilities,
files.associations = files_associations,
ts_settings = ts_settings,
flags = {
debounce_text_changes = 150,
}
}
end
But that does not work.
I also see this structure proposed for Coc ( Configuring coc-phpls and intelephense for Drupal 7 · webschneider.org )
{
"intelephense.environment.documentRoot": "/home/user/git/drupal",
"intelephense.environment.includePaths": ["/home/user/git/drupal/includes"],
"intelephense.files.associations": ["*.php", "*.phtml", "*.module", "*.inc"]
}
I see that for the ts_server there is a function delared that sets internal settings so I tried this:
-- Set settings for language servers below
--
-- tsserver settings
local ts_settings = function(client)
client.resolved_capabilities.document_formatting = false
ts_settings(client)
end
local file_settings = function(client)
files.associations = { '*.install', '*.theme', '*.module', '*.inc' }
file_settings(client)
end
-- local files_associations = { '*.install', '*.theme', '*.module', '*.inc' }
for _, lsp in ipairs(servers) do
nvim_lsp[lsp].setup {
on_attach = on_attach,
capabilities = capabilities,
files_settings = file_settings,
ts_settings = ts_settings,
flags = {
debounce_text_changes = 150,
}
}
end
But that did not work either.
Has anyone gotten file.associations to work with Intelephense LS?