Skip to main content
2 of 2
deleted 15 characters in body
artfulrobot
  • 631
  • 1
  • 5
  • 17

Create a .vim/coc-settings.json file in the root of your project, i.e. /var/www/example/.vim/coc-settings.json

In here you can add settings to override the global ones. Enter this:

{ "coc.preferences.rootPatterns": [ ".thisIsDocRoot" ] } 

This tells CoC to look for a .thisIsDocRoot file to determine a "workspace" dir.

Next touch /var/www/example/.thisIsDocRoot to create a file in the doc root.

Now when you edit a file in /var/www/example/plugins/myplugin CoC will:

  • scan up the tree looking for .vim/coc-settings.json which it will find at the root of your project. It merges that config.
  • that causes it to then look for .thisIsDocRoot, which again it finds in the root of the project.
  • Intelephense now uses this to find symbols.

Note: you might also want to tell it to look in files other than .php ones, e.g. Drupal uses .module and .inc files too. To cover this, my /var/www/example/.vim/coc-settings.json file is:

{ "coc.preferences.rootPatterns": [ ".thisIsDocRoot" ], "intelephense.files.associations": [ "*.php", "*.module", "*.inc" ], "cSpell.userWords": [ "DRUPAL" ] } 

Red herring: Intelephense defines a config item called intelephense.environment.documentRoot. I tried putting a value in this in various coc-settings files to no avail.

artfulrobot
  • 631
  • 1
  • 5
  • 17