Skip to content

An extension for nvim-dap providing configurations for launching kotlin debugger (kotlin-debug-adapter). Allowing you to debug applications and tests

License

Notifications You must be signed in to change notification settings

Mgenuit/nvim-dap-kotlin

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 

Repository files navigation

nvim-dap-kotlin

An extension for nvim-dap providing configurations for launching kotlin debugger (kotlin-debug-adapter) and debugging individual tests.

Features

  • Auto launch kotlin-debug-adapter. No configuration needed. You just have to have kotlin-debug-adapter in your path.
  • Run just the closest test from the cursor in debug mode (uses treesitter). See debugging tests section below for more details.
  • Configuration to start a debug session in the main function.
  • Configuration to start a debug session in the latest cached main function.
  • Configuration to run tests in a debug session.

Pre-reqs

This plugin extension make usage of treesitter to find the nearest test to debug. Make sure you have the Kotlin treesitter parser installed. If using nvim-treesitter plugin you can install with :TSInstall kotlin.

Installation

Plugin

using vim-plug:

Plug 'Mgenuit/nvim-dap-kotlin'
use 'Mgenuit/nvim-dap-kotlin'

using Lazy:

{ "Mgenuit/nvim-dap-kotlin", config = true }

Debug adapter

Using Mason

In neovim

:MasonInstall kotlin-debug-adapter

Using Brew

brew install kotlin-debug-adapter

Usage

Register the plugin

Call the setup function in your init.vim to register the go adapter and the configurations to debug go tests:

lua require('dap-kotlin').setup()

NOTE: When installing with Lazy this step is done by the plugin manager automatically.

Configuring

It is possible to customize nvim-dap-kotlin by passing a config table in the setup function.

The example below shows all the possible configurations:

lua require('nvim-dap-kotlin').setup {
    dap_command = "kotlin-debug-adapter",
    project_root = "${workspaceFolder}",
    enable_logging = false,
    log_file_path = "",
}

Use nvim-dap as usual

  • Call :lua require('dap').continue() to start debugging.
  • All pre-configured debuggers will be displayed for you to choose from.
  • See :help dap-mappings and :help dap-api.

Debugging tests

To debug the closest test method above the cursor use you can select the Closest Test configuration. This support both normal and backtick enclosed method names.

Acknowledgement

Thanks to nvim-dap-go for the inspiration.

About

An extension for nvim-dap providing configurations for launching kotlin debugger (kotlin-debug-adapter). Allowing you to debug applications and tests

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages