fwcd / kotlin-language-server

Kotlin code completion, diagnostics and more for any editor/IDE using the Language Server Protocol
MIT License
1.62k stars 203 forks source link

macos version not support method textDocument/inlayHint. #524

Closed getong closed 9 months ago

getong commented 10 months ago

kotlin-language-server 1.3.7

kotlin code:

fun main() {
    println("Hello, World!")
    val list = listOf(1,2,3)
    print(list)
}

error msg:

Error running timer ‘lsp--on-idle’: (error "The connected server(s) does not support method textDocument/inlayHint.
To find out what capabilities support your server use ‘M-x lsp-describe-session’
and expand the capabilities section")

the lsp-kotlin config:

(use-package lsp-kotlin
  :straight nil
  :custom
  (lsp-kotlin-inlayhints-enable-typehints t)
  (lsp-kotlin-inlayhints-enable-parameterhints t)
  (lsp-kotlin-inlayhints-enable-chainedhints t)
  )

I have check the flag has set:

"kotlin.inlayHints.typeHints": true,
"kotlin.inlayHints.parameterHints": true,
"kotlin.inlayHints.chainedHints": true

I test the sample code with lsp and lsp-bridge, neither can enable inlayHint feature. Only test in macos, not sure linux or windows.

themkat commented 9 months ago

There is no specific Mac OS or Windows or Linux version, they all run on the java virtual machine.

  1. Do you have the latest version of kotlin-language-server from source? Releases don't happen that often due to @fwcd being very busy. (start taking sponsors @fwcd ! Maybe you can escape your job/studies and do open source full time! ❤️ ). I don't think inlay hints is included in any release yet. I would guess this is the issue, based upon your language server output above.
  2. Do you remember to turn on the lsp-inlay-hints-mode? This is how lsp-mode actually present you inlay hints, so you NEED to turn it on. This is standard lsp-mode behaviour, so nothing peculiar we are doing with this language server.

Works perfectly fine on Mac OS when I do it 😛

getong commented 9 months ago

There is no specific Mac OS or Windows or Linux version, they all run on the java virtual machine.

  1. Do you have the latest version of kotlin-language-server from source? Releases don't happen that often due to @fwcd being very busy. (start taking sponsors @fwcd ! Maybe you can escape your job/studies and do open source full time! ❤️ ). I don't think inlay hints is included in any release yet. I would guess this is the issue, based upon your language server output above.
  2. Do you remember to turn on the lsp-inlay-hints-mode? This is how lsp-mode actually present you inlay hints, so you NEED to turn it on. This is standard lsp-mode behaviour, so nothing peculiar we are doing with this language server.

Works perfectly fine on Mac OS when I do it 😛

Which openjdk version do you use ? I use openjdk@17.

And I compile error after gradle build

FAILURE: Build completed with 2 failures.

1: Task failed with an exception.
-----------
* What went wrong:
A problem occurred configuring project ':buildSrc'.
> Failed to calculate the value of task ':buildSrc:compileJava' property 'javaCompiler'.
   > No matching toolchains found for requested specification: {languageVersion=11, vendor=any, implementation=vendor-specific} for MAC_OS on x86_64.
      > No locally installed toolchains match and toolchain download repositories have not been configured.

* Try:
> Learn more about toolchain auto-detection at https://docs.gradle.org/8.4/userguide/toolchains.html#sec:auto_detection.
> Learn more about toolchain repositories at https://docs.gradle.org/8.4/userguide/toolchains.html#sub:download_repositories.
> Run with --stacktrace option to get the stack trace.
> Run with --info or --debug option to get more log output.
> Run with --scan to get full insights.
> Get more help at https://help.gradle.org.
==============================================================================

2: Task failed with an exception.
-----------
* What went wrong:
Failed to query the value of property 'buildFlowServiceProperty'.
> Could not isolate value org.jetbrains.kotlin.gradle.plugin.statistics.BuildFlowService$Parameters_Decorated@7b7cb9d3 of type BuildFlowService.Parameters
   > A problem occurred configuring project ':buildSrc'.
      > Failed to calculate the value of task ':buildSrc:compileJava' property 'javaCompiler'.
         > No matching toolchains found for requested specification: {languageVersion=11, vendor=any, implementation=vendor-specific} for MAC_OS on x86_64.
            > No locally installed toolchains match and toolchain download repositories have not been configured.

* Try:
> Learn more about toolchain auto-detection at https://docs.gradle.org/8.4/userguide/toolchains.html#sec:auto_detection.
> Learn more about toolchain repositories at https://docs.gradle.org/8.4/userguide/toolchains.html#sub:download_repositories.
> Run with --stacktrace option to get the stack trace.
> Run with --info or --debug option to get more log output.
> Run with --scan to get full insights.
> Get more help at https://help.gradle.org.
==============================================================================

BUILD FAILED in 934ms
themkat commented 9 months ago

See Github Actions for build examples. The standard Java version here is Java 11, so for 17 you specify -PjavaVersion=17. So to build the language server for Java 17 you can run ./gradlew :server:installDist -PjavaVersion=17.

getong commented 9 months ago

I install kotlin-language-server by using:

brew install kotlin-language-server

This command by default install openjdk@17, which might be the problem.