weirongxu / coc-kotlin

Intelligent Kotlin support for coc.nvim
MIT License
58 stars 1 forks source link

coc-kotlin fails to start & hangs up at creating client #13

Closed PezCoder closed 1 year ago

PezCoder commented 1 year ago

Result from CocInfo

## versions

vim version: NVIM v0.9.1
node version: v16.15.0
coc.nvim version: 0.0.82-ae4ecfa5 2023-09-03 14:14:50 +0800
coc.nvim directory: /Users/rgupta2/.vim/plugged/coc.nvim
term: tmux
platform: darwin

## Log of coc.nvim

2023-10-29T10:36:48.541 INFO (pid:4311) [plugin] - coc.nvim initialized with node: v16.15.0 after 89
2023-10-29T10:36:52.834 INFO (pid:4311) [core-watchman] - watchman watching project: /Users/rgupta2/Downloads/workspace/marketplace-demand-service
2023-10-29T10:36:53.138 INFO (pid:4311) [language-client-index] - Language server "kotlin" started with 4405
2023-10-29T10:36:57.718 ERROR (pid:4311) [timing] - activate coc-kotlin timeout after 5000ms
2023-10-29T10:37:06.221 INFO (pid:4311) [attach] - Request action: fillDiagnostics [ 3 ]
2023-10-29T10:37:53.609 INFO (pid:4311) [attach] - receive notification: runCommand [ 'workspace.showOutput' ]
2023-10-29T10:38:34.315 INFO (pid:4311) [attach] - receive notification: showInfo []

Description

coc-kotlin fails to start & I don't see any auto completions even after waiting for 10-15 mins.

Extension version

Additional context

Here is what :CocCommand workspace.showOutput says

[10/29/2023, 10:36:52 AM 730] [debug]: Looking for Java in JAVA_HOME (environment variable): /Users/rgupta2/.jenv/versions/11.0
[10/29/2023, 10:36:52 AM 739] [info]: Activating Kotlin Language Server...
[10/29/2023, 10:36:52 AM 743] [info]: Querying GitHub API for new Kotlin Language Server version...
[10/29/2023, 10:36:53 AM 120] [info]: Connecting via Stdio.
[10/29/2023, 10:36:53 AM 129] [info]: Creating client at /Users/rgupta2/.config/coc/extensions/coc-kotlin-data/langServerInstall/server/bin/kotlin-language-server

Try using kotlin-language-server directly works I tried removing coc-kotlin & since it uses kotlin-language-server it works for me!

I cloned & built kotlin-language-server from it repository & added the following in my :CocConfig

    "languageserver": {
        "kotlin": {
            "command": "~/Downloads/workspace/dotfiles/kotlin-language-server/server/build/install/server/bin/kotlin-language-server",
            "filetypes": ["kotlin"],
            "trace.server": "verbose"
        }
    }

The same worked, but I had to wait for 3-5 mins before it starts & have to keep an eye on my workspace.showOutput to know when it's ready to use, so not very convenient. I think coc-kotlin uses this language server under the hood & provide helpful info like the state of plugin & building it etc.

Would you be able to help me debug what the issue might be?

PezCoder commented 1 year ago

I tried removing the ~/.config/coc directory & installed coc-kotlin again & got the following error with :CocInstall coc-kotlin

[coc.nvim] Error: Launching server "kotlin" using command /Users/rgupta2/.config/coc/extensions/coc-kotlin-data/langServerInstall/server/bin/kotlin-la
[coc.nvim]: UnhandledRejection: Launching server "kotlin" using command /Users/rgupta2/.config/coc/extensions/coc-kotlin-data/langServerInstall/server
/bin/kotlin-language-server failed.
Error: Launching server "kotlin" using command /Users/rgupta2/.config/coc/extensions/coc-kotlin-data/langServerInstall/server/bin/kotlin-language-serv
er failed.
    at /Users/rgupta2/.vim/plugged/coc.nvim/build/index.js:244:6399
    at async Md.createConnection (/Users/rgupta2/.vim/plugged/coc.nvim/build/index.js:240:15149)
    at async Md._start (/Users/rgupta2/.vim/plugged/coc.nvim/build/index.js:240:7683)

I tried running this command directly:

/Users/rgupta2/.config/coc/extensions/coc-kotlin-data/langServerInstall/server/bin/kotlin-language-server

& this seem to be working without errors..

PezCoder commented 1 year ago

On opening a kotlin file now, it worked 🎉

For future folks who might be facing this:

martin-braun commented 4 months ago

@PezCoder Oh my god, bless you so much. For future readers, during the reinstallation, when downloading the kotlin language server again, it might fail again, just ignore, let it finish its thing, restart gracefully and give it some time.

At the restart I didn't get the error anymore and after several seconds I finally have Kotlin support. Awesome.