Skip to content

I can't get phpactor to work with coc #1078

Closed

Description

@fcojavierdomenech

I've seen that phpactor might work on coc, but I don't really know how to proceed, these have been my steps so far:

  • Install coc on nvim, on vimrc: Plug 'neoclide/coc.nvim', {'branch': 'release'}
  • Install phpactors coc-extension, on nvim: :CocInstall coc-phpactor
  • Install phpactor globally and created a symlink to make it a command sudo ln -s ~/phpactor/bin/phpactor /usr/local/bin
  • Configure coc-phpactor extension, from nvim do :CocConfig, and created this settings:
{
    "languageserver": {
        "phpactor": {
            "command": "phpactor",
            "trace.server": "verbose",
            "filetypes": ["php"]
        }
    }
}

With these, I restarted nvim, opened a PHP file with some issues:

  • On airline I see a message Starting LS languageserver.phpactor going forever.
  • No autocompletion suggestions (other than the nvim's default autocompletion)
  • Trying to GoToDefinition tells on airline: [coc.nvim] Definition provider not found for current document

Also, just to try out coc I also installed the json extension and everything works perfectly on json files.

Did I miss any configuration step?

Activity

  1. fcojavierdomenech commented on Jun 14, 2020

    @fcojavierdomenech
    ContributorAuthor

    :CocInfo

    ## versions
    
    vim version: NVIM v0.5.0-553-gd8c5d122f
    node version: v12.18.0
    coc.nvim version: 0.0.78-9248f43d6c
    coc.nvim directory: /home/vivo/.vim/plugged/coc.nvim
    term: xterm-256color
    platform: linux
    
    ## Output channel: languageserver.phpactor
    
    [Trace - 3:46:55 PM] Sending request 'initialize - (0)'.
    Params: {
        "processId": 16628,
        "rootPath": "/var/www/html/backend",
        "rootUri": "file:///var/www/html/backend",
        "capabilities": {
            "workspace": {
                ...
    
    
    [Error  - 3:47:03 PM] Connection to server got closed. Server will not be restarted.
    
    
    
  2. dantleech commented on Jun 14, 2020

    @dantleech
    Collaborator

    With the Phpactor COC extension you don't need to configure the language server, just phpactor.enable in :CocConfig

  3. dantleech commented on Jun 14, 2020

    @dantleech
    Collaborator

    My :CocConfig has only:

        "phpactor.enable":true,
        "phpactor.path": "phpactor",
    

    relating to Phpactor.

    Also, Phpactor might be crashing (the Connection to server got closed). Maybe try running phpactor status from the CLI?

  4. fcojavierdomenech commented on Jun 14, 2020

    @fcojavierdomenech
    ContributorAuthor

    Ok, now I tried this coc-settings.json based on yours:

    {
        "languageserver": {
            "phpactor": {
                "command": "/home/vivo/phpactor/bin/phpactor",
                "phpactor.enable":true,
                "phpactor.path": "phpactor",
                "filetypes": ["php"]
            }
        }
    }
    

    Still same problems, this is the phpactor status command from console:

    phpactor [develop] % phpactor status
    Version: 12cd699 (30 hours ago) 2020-06-13-1077
    Filesystems: git, simple, composer
    Working directory: /home/vivo/phpactor
    
    Config files (missing is not bad):
    
      ✘ /home/vivo/.config/phpactor/phpactor.json
      ✘ /home/vivo/.config/phpactor/phpactor.yml
      ✘ /home/vivo/phpactor/.phpactor.json
      ✘ /home/vivo/phpactor/.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.
    
    
    
  5. dantleech commented on Jun 14, 2020

    @dantleech
    Collaborator

    The config is at the root level - my config is f.e. something like:

    {
        "coc.source.around.enable":false,
        "coc.source.buffer.enable":false,
        "coc.source.file.enable":true,
        "diagnostic.displayByAle": false,
        "suggest.autoTrigger":"always",
        "tsserver.trace.server": "verbose",
        "tsserver.enable": true,
        "phpls.trace.server":"verbose",
        "xml.java.home":"/usr/lib/jvm/java-11-openjdk-amd64/",
        "phpactor.enable":true,
        "phpactor.path": "phpactor",
        "diagnostic.virtualText":false,
        "diagnostic.enableSign": true,
        "diagnostic.maxWindowHeight":100,
        "diagnostic.maxWindowWidth":500,
        "python.jediEnabled": true,
        "coc.preferences.useQuickfixForLocations":true,
        "languageserver": {}
    

    (included the empty languageserver key for illustration)

  6. fcojavierdomenech commented on Jun 14, 2020

    @fcojavierdomenech
    ContributorAuthor

    I just tried with this coc-settings:

    {
        "coc.source.around.enable":false,
        "coc.source.buffer.enable":false,
        "coc.source.file.enable":true,
        "diagnostic.displayByAle": false,
        "suggest.autoTrigger":"always",
        "phpactor.enable":true,
        "phpactor.path": "phpactor",
        "diagnostic.virtualText":false,
        "diagnostic.enableSign": true,
        "diagnostic.maxWindowHeight":100,
        "diagnostic.maxWindowWidth":500,
        "coc.preferences.useQuickfixForLocations":true
    }
    

    Now I'm not getting the Starting LS languageserver.phpactor message, but it's not working yet. (i.e getting [coc.nvim] Definition provider not found for current document when going to definition), also where can I find that doc about the settings you have? Sorry if I'm asking dumb questions, but I did not see it anywere while looking how to install it.

  7. dantleech commented on Jun 14, 2020

    @dantleech
    Collaborator

    What if you do :CocCommand phpactor.status ?

  8. fcojavierdomenech commented on Jun 14, 2020

    @fcojavierdomenech
    ContributorAuthor

    I get an error:
    [coc.nvim] Command: phpactor.status not found

    Trying more things, I installed intelliphense and autocompletion and goToDefinition started working...

    Currently I disabled it so I can try phpactor as I told you, these are the list of settings (coc-phpactor is installed!) :/

     * coc-phpactor 1.0.2 ~/.config/coc/extensions/node_modules/coc-phpactor                                                                      
     + coc-json 1.2.6 ~/.config/coc/extensions/node_modules/coc-json
     - coc-phpls 2.1.8 ~/.config/coc/extensions/node_modules/coc-phpls
    
  9. dantleech commented on Jun 14, 2020

    @dantleech
    Collaborator

    Anything different in :CocInfo ? does it attempt to start the language server?

    I see only:

     Starting language server, use -vvv for verbose output
    
  10. fcojavierdomenech commented on Jun 14, 2020

    @fcojavierdomenech
    ContributorAuthor

    :CocInfo seems to do nothing since we put phpactor.enable and phpactor.path on the root settings instead of the initial "languageserver": {"phpactor": { etc`

    ## versions
    
    vim version: NVIM v0.5.0-553-gd8c5d122f
    node version: v12.18.0
    coc.nvim version: 0.0.78-9248f43d6c
    coc.nvim directory: /home/vivo/.vim/plugged/coc.nvim
    term: xterm-256color
    platform: linux
    
    

    If I put the

    {
        "languageserver": {
            "phpactor": {
                "command": "phpactor",
                "trace.server": "verbose",
                "filetypes": ["php"]
            }
        }
    }
    

    then I still have the same output from #1078 (comment)

  11. dantleech commented on Jun 14, 2020

    @dantleech
    Collaborator

    well -- both should work.

    so, one more thing you can try - in a separate terminal:

    $  phpactor language-server --address=0.0.0.0:8890  -vvv
    

    and then set phpactor.enable to false (optionally) and set the following languageserver:

        "languageserver": {
            "phpactor": {
                "enable": true,
                "revealOutputChannelOn": "error",
                "args": ["language-server"],
                "initializationOptions": {
                },
                "filetypes": ["php"],
                "port": 8890,
                "host": "0.0.0.0"
            }
        }
    

    You should then clearly see any fatal error...

  12. fcojavierdomenech commented on Jun 14, 2020

    @fcojavierdomenech
    ContributorAuthor

    Nope haha, with this config it's working!
    I don't know why otherwise it doesn't :/
    Thanks a lot for your work

  13. dantleech commented on Jun 14, 2020

    @dantleech
    Collaborator

    ah ... you're missing the language-server argument in your original config:

    {
        "languageserver": {
            "phpactor": {
                "command": "phpactor",
                "args": ["language-server"],
                "trace.server": "verbose",
                "filetypes": ["php"]
            }
        }
    }
    

    so that would explain that (no need to run the TCP server).
    If that works, it doesn't explain why the CoC extension didn't work though 🤔

  14. dantleech commented on Jun 14, 2020

    @dantleech
    Collaborator

    (Where did you get the instruction for the :CocConfig you started with?)

  15. fcojavierdomenech commented on Jun 14, 2020

    @fcojavierdomenech
    ContributorAuthor

    I just tried your final settings and everything works :)

    Regarding the :CocConfig I just tried to replicate the ones of the README of nvim coc, I tried a few things before from here without success:

    ...
    You have to install coc extension or configure language servers for LSP support.
    
    Install extensions like:
    
    :CocInstall coc-json coc-tsserver
    
    Or configure language server in coc-settings.json opened by :CocConfig, like:
    
    {
      "languageserver": {
        "go": {
          "command": "gopls",
          "rootPatterns": ["go.mod"],
          "trace.server": "verbose",
          "filetypes": ["go"]
        }
      }
    }
    ...
    
  16. dantleech commented on Jun 14, 2020

    @dantleech
    Collaborator

    hmm, ok. guess I need to add more debugging to coc-phpactor and maybe also document the manual configuration.

    Glad it works - shame coc-phpactor doesn't though 👀

  17. fcojavierdomenech commented on Jun 14, 2020

    @fcojavierdomenech
    ContributorAuthor

    Well, to be fair it was my first coc extension ever. But I agree with documenting it.
    I dunno why coc-phpactor failed in my case, are there any more logs I can pass you?
    Anyway, it's working :) Thanks!

  18. dantleech commented on Jun 14, 2020

    @dantleech
    Collaborator

    Not that I'm aware - it's maybe a node JS issue of some kind...

  19. dantleech commented on Jun 20, 2020

    @dantleech
    Collaborator

    ok - found the issue. it requires the tslib dependency. I've published 1.0.3 of the package now, can you try again (:CocInstall coc-phpactor)

  20. dantleech commented on Jun 20, 2020

    @dantleech
    Collaborator

    Closing for now, reopen if it's still broken :)

  21. fcojavierdomenech commented on Jun 23, 2020

    @fcojavierdomenech
    ContributorAuthor

    Just tested, it works, thanks :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions