Skip to content

Settings not taken into account #591

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
greg0ire opened this issue Aug 22, 2024 · 9 comments
Closed

Settings not taken into account #591

greg0ire opened this issue Aug 22, 2024 · 9 comments

Comments

@greg0ire
Copy link

greg0ire commented Aug 22, 2024

I can see this error on some lines:

Cannot inline bytecode built with JVM target 11 into bytecode that is being built with JVM target 1.8. Please specify proper '-jvm-target' option [INLINE_FROM_HIGHER_PLATFORM]

I've seen #72, so I tried to fix it like this:

require("mason-lspconfig").setup_handlers {
    function (server_name) -- default handler (optional)
      if server_name == "kotlin_language_server" then
        require("lspconfig")["kotlin_language_server"].setup {
          on_attach=custom_lsp_attach,
          capabilities = require('cmp_nvim_lsp').default_capabilities(),
          settings = {
            kotlin = {
              compiler = {
                jvm = {
                  target = "11"
                }
              }
            }
          }
        }
      end
      require("lspconfig")[server_name].setup {
        on_attach=custom_lsp_attach,
        capabilities = require('cmp_nvim_lsp').default_capabilities()
      }
    end,
}

That does not seem to have any effect. How do I troubleshoot this?

@fwcd
Copy link
Owner

fwcd commented Aug 22, 2024

Could you test if it works in VSCode? Just to rule out that it's not an editor/client-specific issue.

@greg0ire
Copy link
Author

I am unfamiliar with VS Code but I installed it (pacman -S code), and then I installed this, but I don't have the INLINE_FROM_HIGHER_PLATFORM. Instead, I have a lot of UNRESOLVED_REFERENCE, for types that come from dependencies it seems.

@fwcd
Copy link
Owner

fwcd commented Aug 22, 2024

Then the language server may have trouble finding your dependencies. Try a vanilla Gradle or Maven project, if that works, try finding the differences to your project.

@greg0ire
Copy link
Author

Ah I just saw that the page for the extension mentions that it must be a Maven or Gradle project. I'm using Gradle, but I guess I must also install a Gradle extension for vscode? I'm installing the "Gradle for Java" extension

@fwcd
Copy link
Owner

fwcd commented Aug 22, 2024

In principle Kotlin should suffice

@greg0ire
Copy link
Author

greg0ire commented Aug 22, 2024

I'll try with https://github.com/fwcd/kotlin-quick-start then

Step 1: finding the right openjdk version for it. It does not seem to be openjdk-21:

General error during conversion: Unsupported class file major version 65

EDIT: v17 seems to build. Step1 done.
Now trying to reproduce the INLINE_FROM_HIGHER_PLATFORM issue.

Step2: reproducing the Neovim: ✔️
I installed mockito 5.0.0 (testImplementation("org.mockito.kotlin:mockito-kotlin:5.0.0")), then edited a test to add
private val appMock: App = mock()

Step3: reproducing the issue with VSCode ✔️

Step 4: changing the setting in VSCode ✔️

@greg0ire
Copy link
Author

greg0ire commented Aug 22, 2024

Changing the setting VSCode fixes the issue, so it would seem the issue is Neovim-specific. It would be great if there was a way for me to see what settings Neovim sends to kotlin-language-server.

EDIT: here is what I get when I type :LspLog in Neovim:

[START][2024-08-22 22:39:41] LSP logging initiated
[ERROR][2024-08-22 22:39:41] .../vim/lsp/rpc.lua:770	"rpc"	"kotlin-language-server"	"stderr"	'SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder".\nSLF4J: Defaulting to no-operation (NOP) logger implementation\n'
[ERROR][2024-08-22 22:39:41] .../vim/lsp/rpc.lua:770	"rpc"	"kotlin-language-server"	"stderr"	"SLF4J: See http://www.slf4j.org/codes.html#StaticLoggerBinder for further details.\n"

@greg0ire
Copy link
Author

greg0ire commented Aug 22, 2024

OK… I am stupid 🤦

 require("mason-lspconfig").setup_handlers {
     function (server_name) -- default handler (optional)
       if server_name == "kotlin_language_server" then
         require("lspconfig")["kotlin_language_server"].setup {
           on_attach=custom_lsp_attach,
           capabilities = require('cmp_nvim_lsp').default_capabilities(),
           settings = {
             kotlin = {
               compiler = {
                 jvm = {
                   target = "11"
                 }
               }
             }
           }
         }
+          return
       end
       require("lspconfig")[server_name].setup {
         on_attach=custom_lsp_attach,
         capabilities = require('cmp_nvim_lsp').default_capabilities()
       }
     end,
 }

Thanks for your answers, and great work with this LSP!

@fwcd
Copy link
Owner

fwcd commented Aug 22, 2024

Glad to hear you fixed it!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants