coc-phpactor icon indicating copy to clipboard operation
coc-phpactor copied to clipboard

Unclear if coc-phpactor is working with vim9

Open vendion opened this issue 3 years ago • 17 comments

I'm trying to get Phpactor and coc-phpactor setup under Vim 9, I have the vim plugin and phpactor itself installed as well as have coc-phpactor installed and enabled.

The problem is it seems that Coc.nvim isn't able to talk to phpactor, what I mean by this is things like :CocCommand phpactor.status, :CocCommand phpactor.reindex, :CocCommand phpactor.services.list generate no output when ran, there is no code completion offered, and things like Hover and GoTo Definiton just hang forever.

Output of :CocInfo

## versions

vim version: VIM - Vi IMproved 9.0 9000000
node version: v16.16.0
coc.nvim version: 0.0.81-2522eee5 2022-06-14 19:03:29 +0800
coc.nvim directory: /home/vendion/.vim/plugged/coc.nvim
term: tmux
platform: linux

## Log of coc.nvim

2022-07-13T16:47:42.366 INFO (pid:2782975) [services] - registered service "languageserver.golang"
2022-07-13T16:47:42.368 INFO (pid:2782975) [services] - registered service "languageserver.ccls"
2022-07-13T16:47:42.368 INFO (pid:2782975) [services] - registered service "languageserver.elvish"
2022-07-13T16:47:42.466 INFO (pid:2782975) [coc-git] - Looking for git in: git
2022-07-13T16:47:42.505 INFO (pid:2782975) [services] - registered service "json"
2022-07-13T16:47:42.506 INFO (pid:2782975) [services] - Json language server state change: stopped => starting
2022-07-13T16:47:42.722 INFO (pid:2782975) [plugin] - coc.nvim initialized with node: v16.16.0 after 591ms
2022-07-13T16:47:42.784 INFO (pid:2782975) [language-client-index] - Language server "phpactor" started with 2783078
2022-07-13T16:47:42.883 INFO (pid:2782975) [services] - Json language server state change: starting => running
2022-07-13T16:47:42.889 INFO (pid:2782975) [services] - service json started
2022-07-13T16:48:03.247 INFO (pid:2782975) [attach] - Request action: commandList [ 'phpa', 'CocCommand phpa', 15 ]
2022-07-13T16:48:07.332 INFO (pid:2782975) [attach] - receive notification: runCommand [ 'phpactor.status' ]
2022-07-13T16:48:07.859 INFO (pid:2782975) [attach] - receive notification: highlight []
2022-07-13T16:48:07.860 INFO (pid:2782975) [attach] - receive notification: highlight []
2022-07-13T16:48:09.717 INFO (pid:2782975) [attach] - receive notification: highlight []
2022-07-13T16:48:09.718 INFO (pid:2782975) [attach] - receive notification: highlight []
2022-07-13T16:48:32.135 INFO (pid:2782975) [attach] - receive notification: highlight []
2022-07-13T16:48:32.137 INFO (pid:2782975) [attach] - receive notification: highlight []
2022-07-13T16:48:38.580 INFO (pid:2782975) [attach] - receive notification: showInfo []

Output of :PhpactorStatus

Version: "2b995dce (13 hours ago) Add-initial-support-for-templated-class-string
Filesystems: git, simple, composer
Working directory: /home/vendion/work/Juice4-STS6

Config files (missing is not bad):

✘ /home/vendion/.config/phpactor/phpactor.json
✘ /home/vendion/.config/phpactor/phpactor.yml
✘ /home/vendion/work/Juice4-STS6/.phpactor.json
✘ /home/vendion/work/Juice4-STS6/.phpactor.yml

Diagnostics:

✔ Composer detected - Phpactor could work faster without an index
✔ Git detected - enables faster refactorings in your repository scope!
✔ XDebug is disabled. XDebug has a negative effect on performance.

vendion avatar Jul 13 '22 20:07 vendion

hm, as far as CoC or other LSP clients are concerned Phpactor is agnostic to the VIM version. Does it work in Neovim?

you coud enable logging in Phpactor to see if it's getting any requests: https://phpactor.readthedocs.io/en/master/other/developing.html

dantleech avatar Jul 14 '22 05:07 dantleech

I don't have Neovim installed or even configured, but I did enable logging and it does seem to be getting requests from CoC.

phpactor.log

vendion avatar Jul 14 '22 13:07 vendion

hm I don't see any requests in that log, looks like it's just indexing....

dantleech avatar Jul 14 '22 14:07 dantleech

Okay let's try this one including a screenshot showing that CoC is requesting hover information:

phpactor.log Screenshot_20220714_111537

vendion avatar Jul 14 '22 14:07 vendion

I do know that CoC works, as I have no problem with the Go, Vim, Perl, Elvish language servers and even coc-phpls (using Intelephense) works with this same project (would just rather use an open source solution and Phpactor looks like the better option).

vendion avatar Jul 14 '22 14:07 vendion

ah, may be you need to enable trace: https://phpactor.readthedocs.io/en/master/reference/configuration.html#language-server-trace

then grep for TRAC

dantleech avatar Jul 14 '22 15:07 dantleech

Doing so I see tho following line in the log:

[2022-07-14 17:16:37] phpactor.INFO: TRAC << {"jsonrpc":"2.0","id":"dea8fe25-03cd-41ff-94f4-8b86ad4e3a2c","result":null} {"channel":"LSP","jsonrpc":"2.0","id":"dea8fe25-03cd-41ff-94f4-8b86ad4e3a2c","result":null,"error":null} []
[2022-07-14 17:16:38] phpactor.INFO: TRAC >> {"jsonrpc":"2.0","id":1,"method":"textDocument\/codeAction","params":{"textDocu⋯ {"channel":"LSP","jsonrpc":"2.0","id":1,"method":"textDocument/codeAction","params":{"textDocument":{"uri":"file:///home/vendion/work/Juice4-STS6/juice-myaccount.php"},"range":{"start":{"line":467,"character":22},"end":{"line":467,"character":22}},"context":{"diagnostics":[]}}} []

vendion avatar Jul 14 '22 17:07 vendion

ok, not sure if it's interesting but it's using a UUID for the response for the first request, and the second request is issuing (from the client and ID of 1). Will try CoC with Neovim (which I used for years before switching to the native LSP client) else maybe it's somehow a difference with CoC and VIM 9 that Phpactor doesn't handle properly.

dantleech avatar Jul 14 '22 21:07 dantleech

Can confirm that Phpactor + CoC + Neovim work so maybe a complication with vim 9 :/

dantleech avatar Jul 17 '22 11:07 dantleech

I am actually using Vim 9 with coc and phpactor and I didn't notice any particular issue.

lukepass avatar Jul 27 '22 12:07 lukepass

hm, running in Windows by the looks of the screenshot? On WSL? Wonder if that complicates it somehow (Phpactor is not compatible with Windows AFAIK, but I guess it runs on WSL)

dantleech avatar Jul 27 '22 13:07 dantleech

@vendion's screenshot seems from KDE. I am using Xubuntu and all is working correctly!

lukepass avatar Jul 27 '22 13:07 lukepass

oh well, i seem to be not up to date on either Windows or KDE :smile:

dantleech avatar Jul 27 '22 14:07 dantleech

I am indeed using KDE using Arch Linux as my distribution.

vendion avatar Jul 28 '22 20:07 vendion

Just to clarify is there anything special that needs to be set in coc-settings.json apart from phpactor.enable and phpactor.path?

Here is what I have in mine

{
  "languageserver": {
    "ccls": {
      "command": "ccls",
      "filetypes": ["c", "cc", "cpp", "c++", "objc", "objcpp"],
      "rootPatterns": [".ccls", "compile_commands.json", ".git/", ".hg/"],
      "initializationOptions": {
      "cache": {
        "directory": "/tmp/ccls"
      }
    }
  },
  "elvish": {
    "command": "elvish",
    "args": ["-lsp"],
    "filetypes": ["elvish"],
    "rootPatterns": [".elv"]
    }
  },
  "intelephense.licenceKey": "(redacted)",
  "diagnostic.displayByAle": true,
  "phpls.enable": false,
  "phpactor.enable": true,
  "phpactor.path": "$HOME/.vim/plugged/phpactor/bin/phpactor",
  "Lua.telemetry.enable": true
}

vendion avatar Jul 29 '22 19:07 vendion

my setup is a ltittle different, but not sure it would make a diff:

{
    "coc.source.around.enable":false,
    "coc.source.buffer.enable":false,
    "coc.source.file.enable":true,
    "coc.preferences.enableFloatHighlight":true,
    "coc.preferences.currentFunctionSymbolAutoUpdate":true,
    "phpactor.enable": true,
    "phpactor.path": "phpactor",
    "phpactor.debug": true,
    "phpactor.revealOutputChannelOn":"warn",
    "coc.preferences.enableMessageDialog":false,
    "phpactor.trace.server":"error",
    "suggest.floatEnable": false,
    "phpactor.config": {
        "logging.level": "error",
        "logging.enabled": true,
        "logging.path": "/home/daniel/www/phpactor/phpactor-session.log",
        "language_server.diagnostic_sleep_time": 1000,
        "language_server.diagnostics_on_update": false,
        "language_server_completion.trim_leading_dollar": false,
        "language_server_phpstan.level": 7,
        "language_server_phpstan.enabled": false
    },
    "diagnostic.virtualText":false,
    "diagnostic.enableSign": true,
    "diagnostic.maxWindowHeight":100,
    "diagnostic.maxWindowWidth":500,
    "coc.preferences.useQuickfixForLocations":true
}

dantleech avatar Jul 30 '22 00:07 dantleech

I thought I had it figured out, as I opened a different project, one that is built on Laravel, and phpactor worked there so I thought it was just an issue between that project and phpactor.

What caused me to have doubts is I recently setup neovim + native LSP and phpactor is working without any issues in both projects. :shrug:

vendion avatar Aug 06 '22 02:08 vendion