phpactor / coc-phpactor

Phpactor CoC Extension
https://github.com/phpactor/phpactor
MIT License
28 stars 3 forks source link

enable this extension also for behat cucumber files #36

Open Trim opened 7 months ago

Trim commented 7 months ago

Hello,

According to the phpactor behat integration documentation, I have to configure the language server to be enabled on "php" and "cucumber" file types.

If I read correctly, currently the coc-phpactor extension enables the phpactor language server only for php files.

Is it possible to add cucumber files too by default or to add an extension option to enable the language server for these files ?

dantleech commented 7 months ago

I guess it should be fine. If the supported file types are set in the coc extebsion then feel free to make an MR :)

Trim commented 7 months ago

Well, I've just tried to create a patch to add cucumber file type for the extension, but it did not work: https://github.com/Trim/coc-phpactor/commit/985ad76ac850886373397db29c3fd96231a544bf

After applying this patch:

  1. I run yarn install to rebuild the extension
  2. I open a feature file with vim feature/some.feature with a vim installation which has coc.nvim installed without the coc-phpactor. The project is a new Symfony7 project with this phpactor configuration:
    {
    "$schema": "/var/home/adrien/.local/applications/phpactor/phpactor.schema.json",
    "symfony.enabled": true,
    "indexer.exclude_patterns": [
        "/vendor/**/Tests/**/*",
        "/vendor/**/tests/**/*",
        "/var/cache/**/*",
        "/vendor/composer/**/*"
    ],
    "behat.enabled": true,
    "behat.symfony.di_xml_path": "%project_root%/var/cache/dev/App_KernelDevDebugContainer.xml"
    }
  3. I use the vim command :set runtimepath^=~/code/coc-phpactor/ with path to my patched coc-phpactor directory
  4. I run the vim command :CocInfo and I have these logs:
## versions

vim version: VIM - Vi IMproved 9.1 9010031
node version: v20.10.0
coc.nvim version: 0.0.82-d1568d56 2023-09-29 19:43:34 +0800
coc.nvim directory: /var/home/adrien/code/config/vim/pack/adrien/start/coc.nvim
term: tmux
platform: linux

## Log of coc.nvim

2024-01-22T21:43:27.647 INFO (pid:123131) [configurations] - Add folder configuration from file: /var/home/adrien/.vim/coc-settings.json
2024-01-22T21:43:27.785 INFO (pid:123131) [extension:coc-git] - Looking for git in: git
2024-01-22T21:43:27.977 INFO (pid:123131) [plugin] - coc.nvim initialized with node: v20.10.0 after 549
2024-01-22T21:44:27.492 INFO (pid:123131) [attach] - receive notification: highlight []
2024-01-22T21:44:31.096 INFO (pid:123131) [attach] - receive notification: showInfo []
  1. Although, if I open a PHP file I see well the log message:
2024-01-22T21:48:57.033 INFO (pid:123131) [language-client-index] - Language server "phpactor" started with 124058

I don't understand why it doesn't work for cucumber files as I've never did a coc-nvim extension before. Some help would be appreciated :)

For the moment, I've set this coc configuration which seems to do the same thing than the coc-phpactor extension, but it works well for both php and cucumber files:

{
  "languageserver": {
    "local-phpactor": {
      "enable": true,
      "filetypes": ["php", "cucumber"],
      "command": "phpactor",
      "args": ["language-server"]
    }
  }
}