Skip to content

DAP support kotlin

Zeioth edited this page Aug 28, 2023 · 2 revisions

Nothing special needs to be done for kotlin.

How to configure DAP for java

Please note that this section has nothing to do with compiler.nvim. I'm documenting this to make your life easier. To debug kotlin with DAP you have to:

  • Install kotlin-debug-adapter using Mason.
  • Setup DAP for kotlin.

Here you have an example of how to configure DAP for Kotlin

-- Kotlin
-- Kotlin projects have very weak project structure conventions.
-- You must manually specify what the project root and main class are.
dap.adapters.kotlin = {
  type = 'executable';
  command = vim.fn.stdpath('data')..'/mason/bin/kotlin-debug-adapter',
}
dap.configurations.kotlin = {
    {
        type = 'kotlin';
        request = 'launch';
        name = 'Launch kotlin program';
        projectRoot = "${workspaceFolder}/app"; -- ensure this is correct
        mainClass = "AppKt";                    -- ensure this is correct
    };
}

Important for you to know

  • If you find any issue while configuring DAP, run :DapSetLogLevel trace and :DapShowLog to find the reason.