GithubHelp home page GithubHelp logo

mfussenegger / nvim-dap Goto Github PK

View Code? Open in Web Editor NEW
4.8K 23.0 172.0 645 KB

Debug Adapter Protocol client implementation for Neovim

License: GNU General Public License v3.0

Lua 99.90% Python 0.07% Vim Script 0.02%
neovim neovim-plugin debug-adapter-protocol debugger

nvim-dap's Introduction

DAP (Debug Adapter Protocol)

nvim-dap is a Debug Adapter Protocol client implementation for Neovim. nvim-dap allows you to:

  • Launch an application to debug
  • Attach to running applications and debug them
  • Set breakpoints and step through code
  • Inspect the state of the application

demo

Installation

LuaRocks

  • Install nvim-dap like any other Neovim plugin:
    • git clone https://github.com/mfussenegger/nvim-dap.git ~/.config/nvim/pack/plugins/start/nvim-dap
    • Or with vim-plug: Plug 'mfussenegger/nvim-dap'
    • Or with packer.nvim: use 'mfussenegger/nvim-dap'
  • Generate the documentation for nvim-dap using :helptags ALL or :helptags <PATH-TO-PLUGIN/doc/>

Supported Neovim versions:

  • Latest nightly
  • 0.9.x (Recommended)
  • 0.8.3

You'll need to install and configure a debug adapter per language. See

Usage

A typical debug flow consists of:

  • Setting breakpoints via :lua require'dap'.toggle_breakpoint().
  • Launching debug sessions and resuming execution via :lua require'dap'.continue().
  • Stepping through code via :lua require'dap'.step_over() and :lua require'dap'.step_into().
  • Inspecting the state via the built-in REPL: :lua require'dap'.repl.open() or using the widget UI (:help dap-widgets)

See :help dap.txt, :help dap-mapping and :help dap-api.

Supported languages

In theory all of the languages for which a debug adapter exists should be supported.

The Wiki is community maintained. If you got an adapter working that isn't listed yet, please extend the Wiki.

Some debug adapters have language specific extensions. Using them over a manual configuration is recommended, as they're usually better maintained.

If the instructions in the wiki for a debug adapter are not working, consider that debug adapters may have made changes since the instructions were written. You may want to read the release notes of the debug adapters or try with an older version. Please update the wiki if you discover outdated examples.

Goals

  • Have a basic debugger in Neovim.

  • Extensibility and double as a DAP client library. This allows other plugins to extend the debugging experience. Either by improving the UI or by making it easier to debug parts of an application.

Extensions

All known extensions are listed in the Wiki. The wiki is community maintained. Please add new extensions if you built one or if you discovered one that's not listed.

Non-Goals

  • Debug adapter installations are out of scope. It's not the business of an editor plugin to re-invent a package manager. Use your system package manager. Use Nix. Use Ansible.

  • nvim-dapconfig

  • Vim support. It's not going to happen. Use vimspector instead.

Alternatives

Contributing

Contributions are welcome:

  • Give concrete feedback about usability.
  • Triage issues. Many of the problems people encounter are debug adapter specific.
  • Improve upstream debug adapter documentation to make them more editor agnostic.
  • Improve the Wiki. But please refrain from turning it into comprehensive debug adapter documentation that should go upstream.
  • Write extensions.

Before making direct code contributions, please create a discussion or issue to clarify whether the change is in scope of the nvim-dap core.

Please keep pull requests focused and don't change multiple things at the same time.

Features

  • launch debug adapter
  • attach to debug adapter
  • toggle breakpoints
  • breakpoints with conditions
  • logpoints
  • set exception breakpoints
  • step over, step into, step out
  • step back, reverse continue
  • Goto
  • restart
  • stop
  • pause
  • evaluate expressions
  • REPL (incl. commands to show threads, frames and scopes)

nvim-dap's People

Contributors

acksld avatar andmis avatar asmodeus812 avatar bliznyuknm avatar ckipp01 avatar danielnehrig avatar dchusovitin avatar dubrayn avatar j0le avatar jbyuki avatar kasama avatar kconston avatar ktakiman avatar ldelossa avatar leblocks avatar lervag avatar mariasolos avatar mfussenegger avatar mrcjkb avatar nicholasmata avatar nsteinhoff avatar patoconnor43 avatar rcarriga avatar shatur avatar thehamsta avatar theleop avatar weihanglo avatar williamboman avatar wookayin avatar y1rn avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

nvim-dap's Issues

How do I run a specific job or task?

In IntelliJ in my Scala project I can right click and set a breakpoint and then in the upper right there's a dropdown where I can choose what task/job to run and then click on the bug icon and that runs the job. I can click 'edit' on that job as well and change the params. I'm trying to accomplish the same with DAP.

So far with nvim-dap I can set a breakpoint, open the repl, and run "continue" which prompts me with Run, Test File, and Test Target.

So for example if I have the following in my build.sbt.

addCommandAlias("foo", "runMain com.mycompany.Foo")

and then I have a file

package com.mycompany

object Foo extends App {
  def whatever = {
    // BREAKPOINT HERE
  }
}

How do I hit this breakpoint? How do I run sbt foo in nvim with DAP and hit this breakpoint like I can in IntelliJ?

Here's my dap config.

dap.configurations.scala = {
  {
    type = "scala",
    request = "launch",
    name = "Run",
    metalsRunType = "run",
  },
  {
    type = "scala",
    request = "launch",
    name = "Test File",
    metalsRunType = "testFile",
  },
  {
    type = "scala",
    request = "launch",
    name = "Test Target",
    metalsRunType = "testTarget",
  },
}

DAP setup for Ruby

I'm trying to setup DAP for ruby/rails using Readapt .
I'm referencing the configuration of vscode-ruby-debug.
I've DAP setup as follow:

local dap = require('dap')

dap.adapters.ruby = {
	type = 'executable';
	command = 'bundle';
	args = {'exec', 'readapt', 'stdio'};
}

dap.configurations.ruby = {
	type = 'ruby';
	request = 'launch';
	name = 'Rails';
	program = 'bundle';
	programArgs = {'exec', 'rails', 's'};
	useBundler = true;
}

I got message: No configuration found for ruby.
What's the problem with the aforementioned setup?

Use new overlay virtual text for column break points

DAP in theory supports stepping and breakpoints with column granularity (I guess only the JS debugger supports it). It might be useful to display such column breakpoints/in column step target with the new "overlay virtual text (neovim/neovim#13952, show arrows as overlays in next line to indicate the respective columns)

Provide commands `up` and `down`

I have a question about a spot in the code of nvim-dap

for _, frame in pairs(frames_resp.stackFrames) do

      for _, frame in pairs(frames_resp.stackFrames) do
        if not current_frame then
          current_frame = frame
          self.current_frame = frame
        end
        frames[frame.id] = frame
      end

Why is pairs instead of ipairs used and frames.id instead of i doesn't this cause us to loose track of the order of the frames?

I would love to have the commands up and down in repl where you can quickly switch between the different stack levels without any stepping. When using a stepping command, the debugger would first return to the current frame before the actual stepping command is applied. So step_over step_out is always relative to the current stack frame. gdb and pdb both provide those two commands and I really missed them when using vscode for debugging.

repl.open() opens extra buffer

When I executing :lua require'dap'.repl.open() I have dap_repl buffer and one extra empty buffer.

Steps to reproduce

Configuration: dap_config.lua

:lua require'dap'.repl.open()
:bnext " You will see dap_repl buffer
:bnext " You will see an empty buffer
:bnext " You will see the previous buffer before opening repl

Screenshot

изображение

Setting request: open repl in vertical split

This might be a very small change.
I imagine an option like this:

:lua require'dap'.repl.open({ vsplit = true })

Maybe with a position?
So we can choose exactly where to open REPL.
In this example we would open it in a vertical split right of the current window.

:lua require'dap'.repl.open({ vsplit = true, pos = 'upper_right' })

To be error proof: [ 'upper_right', 'lower_left' ] could indicate the desired position.

Are you open to configurable ui options?

So when using dap.ui.variables".scopes() it opens up a window that blends with the background, and it's a bit difficult in some situations to know where stuff ends for the window etc.

Here is an example:

Screenshot 2021-04-23 at 15 49 15

With no theme just to show it's not theme related or something:

Screenshot 2021-04-23 at 15 53 16

Would you be open to having the user be able to pass in win options to change the blend or to add a border or something?

Unable to connect to X Server

I have an issue with lldb-vscode. My project is unable to connect to X server with DebugC <path>. But works with plain start.
I have lldb 10.0.0 installed and lldb-vscode is in my PATH.
Example project: akd
Screenshot (the message from akd, the application can't open connection to X11):
изображение

help setting up lldb-vscode for cpp

Thank you for the excellent step-by-step wiki, but unfortunately I still have problems 😅

init.lua:

local api = vim.api

api.nvim_command('packadd packer.nvim')
api.nvim_set_option("termguicolors", true)
api.nvim_set_var("oak_virtualtext_bg", 1)
api.nvim_set_var("conjure#mapping#doc_word", ",K")

local packer = require('packer')
local packages = require('packages')

packer.startup(function()
  for _, value in pairs(packages) do
    packer.use(value)
  end
end)

vim.cmd [[
    command! -complete=file -nargs=* DebugC lua require "dap_setup".start_c_debugger({<f-args>}, "gdb")
]]

lua/dap_adapters.lua:

local dap = require "dap"
dap.adapters.cpp = {
  type = "executable",
  attach = {
    pidProperty = "pid",
    pidSelect = "ask"
  },
  command = "lldb-vscode", -- my binary was called 'lldb-vscode-11'
  env = {
    LLDB_LAUNCH_FLAG_LAUNCH_IN_TTY = "YES"
  },
  name = "lldb"
}

lua/dap_setup.lua:

-- In a file lua/my_debug.lua
local M = {}
local last_gdb_config

M.start_c_debugger = function(args, mi_mode, mi_debugger_path)
  local dap = require "dap"
  require "dap_adapters"
    if args and #args > 0 then
        last_gdb_config = {
            type = "cpp",
            name = args[1],
            request = "launch",
            program = table.remove(args, 1),
            args = args,
            cwd = vim.fn.getcwd(),
            env = {"VAR1=value1", "VAR2=value"}, -- environment variables are set via `ENV_VAR_NAME=value` pairs
            externalConsole = true,
            MIMode = mi_mode or "gdb",
            MIDebuggerPath = mi_debugger_path
          }
    end

    if not last_gdb_config then
        print('No binary to debug set! Use ":DebugC <binary> <args>" or ":DebugRust <binary> <args>"')
        return
    end

    dap.run(last_gdb_config)
    --dap.repl.open()
end

return M

:help dap does not link to help file

:help dap links to delete a paragraph instead of dap.txt, (just needs to be changed in readme i think)

also it would be nice if helptags ran by default, I'll try and implement this if I can figure it out.

Using NVIM v0.5.0-dev+950-g5ce328df4

C#: Can't debug with netcoredbg without setting a breakpoint

I have got installed netcoredbg using vimspector and have got it to work if I set a breakpoint. However, when I don't set a breakpoint I get the following error message and the debugger never starts.

Error executing vim.schedule lua callback: ...nvim/site/pack/packer/start/nvim-dap/lua/dap/session.lua:109: attempt to index field 'capabilities' (a nil value)

Output from the log flie:

[ WARN ] 2021-05-10T03:05:13Z-0400 ] ...nvim/site/pack/packer/start/nvim-dap/lua/dap/session.lua:530 ] "No event handler for " {
body = {
capabilities = {
supportTerminateDebuggee = true,
supportsConditionalBreakpoints = true,
supportsConfigurationDoneRequest = true,
supportsExceptionInfoRequest = true,
supportsFunctionBreakpoints = true,
supportsSetVariable = true
}
},
event = "capabilities",
seq = 1,
type = "event"
}

Config that I am using:

local dap = require("dap")

local function pwd() return io.popen("pwd"):lines()() end

dap.adapters.netcoredbg = {
    type = "executable",
    command = XDG_DATA_HOME .. "/vimspector-config/gadgets/linux/netcoredbg/netcoredbg",
    args = {
        "--interpreter=vscode",
        string.format("--engineLogging=%s/netcoredbg.engine.log", XDG_CACHE_HOME),
        string.format("--log=%s/netcoredbg.log", XDG_CACHE_HOME),
    },
}

dap.configurations.cs = {
    {
        type = "netcoredbg",
        name = "launch - netcoredbg",
        request = "launch",
        program = function()
            local dll = io.popen("find bin/Debug/ -maxdepth 2 -name \"*.dll\"")
            return pwd() .. "/" .. dll:lines()()
        end,
        stopAtEntry = true,
    },
}

Debugpy wiki wrong

I recently took my time to check out this plugin, and it looks awesome! I thought I would just let you know that there is a small problem with the wiki for debugpy. In the debugpy.configurations.python where dap is looking for an executable, this should be compared to 1. Help page is stating that executable is returning either 1, 0 or -1, and all of them returns true. Just thought I would share this so others don't understand why it won't configure correctly

No configuration found for cpp

Hi,

Most likely I am an idiot, but unfortunately I keep getting a No configuration found for cpp in my cpp projects. This is my configuration:

            'mfussenegger/nvim-dap',
            config = function()
                local dap = require'dap'
                dap.adapters.cpp = {
                    type = 'executable',
                    attach = {
                        pidProperty = "pid",
                        pidSelect = "ask"
                    },
                    command = 'lldb-vscode',
                    env = {
                        LLDB_LAUNCH_FLAG_LAUNCH_IN_TTY = "YES"
                    },
                    name = "lldb"
                }
            end
        }

in my packer configuration.
Output of which lldb-vscode:

/usr/bin/lldb-vscode

System: Arch lts latest, nvim-nightly latest
Any help is greatly appreciated!

exit() and toggle() functions

I see that some functions, such as .up(), .stop(), .continue() and other can be called from REPL and from lua directly.
But .exit function cannot be called from lua. Could you export it to Lua API? To have the ability to map something like lua require'dap'.exit() to a key.

Another suggestion is add toggle() function. Like in Asyncrun. What do you think about it?

Hover moves the cursor on itself

When I use lua require("dap.ui.variables").hover() my cursor moves inside the popup. Also, when I exit it, it does not disappear as it usually does with hover windows from LSP.

REPL filetype

Could you assign a filetype to REPL? This will allow to configure it layout. For example, to fix buffer height to 20 or make it unlisted.

Python adapter crashes Neovim

Hello,

I have tried to follow the examples given in the manual and I get very weird behaviour with the debugpy adapter.

My configuration

dap.adapters.python = {
	type = 'executable',
	command = '/usr/bin/python3',
	args = {'-m', 'debugpy.adapter'}
}

dap.configurations.python = {
	{
		type = 'python',
		request = 'launch',
		name = 'Launch file',
		program = "${file}",
		pythonPath = function(adapter)
			return '/usr/bin/python3'
		end,
	}
}

The code

Here is the Python script I want to debug

#!/bin/env python3

def test_fun(x, y):
    print('This is a test function')
    print('The value of x is ' + str(x))
    print('The value of y is ' + str(y))
    sum = x + y
    print('The sum is ' + str(sum))
    print('bye')

test_fun(2, 3)

Whether the file is executable or not does not matter.

What goes wrong

I set a break point on line 6, open a debug REPL, then start the debugger with lua require"dap".continue(). The debugger stops on the break point and the REPL shows the printed lines. Everything good so far.

However, once I press any key, even if it is just to move the cursor, Neovim gets suspended as if I had pressed CTRL-Z. If I try resuming it with fg everything is totally borked for lack of a better word, and I can only CTRL-C to quit.

I have not been able to test other adapters, I wanted to get this one working first because it's the easiest one to set up. While I'm at it, what are the keys to use in the dap.configurations.<whatever> table? Do they depend on the particular adapter?

Trouble setting up with python

I just getting started with nvim-dap and am having troubles setting it up with python. I have the following config

local dap = require('dap')
dap.adapters.python = {
    type = 'executable',
    command = 'python',
    args = {'-m', 'debugpy.adapter'}
}
dap.configurations.python = {
    {
        type = 'python',
        require = 'launch',
        name = "Launch file",
        program = "${file}",
        pythonPath = function() return '/usr/bin/python' end,
    },
}

which debugpy installed in my base python environment.

As I test I'm trying to debug the following file

def some():
    print("hello")

if __name__ == '__main__':
    some()

if I go the to line with the print statement and do :lua require"dap".toggle_breakpoint() I get a B in the margin. However when I do :lua require"dap".continue() nothing happens and if I do it again I get No stopped thread. Cannot move. Any idea what I'm doing wrong?

Running a different command without sourcing configurations

What is the recommended approach to running a different command or sending different options to the debug adapter prior to running nvim-dap?

An example would be; while working on a python file, debug that file with a normal run of debugpy then create a test case for the file and debug it with the testing module such as pytest.

Lowercase `dap` global is a bit confusing

So I know you have the dap global here:

dap = {} -- luacheck: ignore 111 - to support v:lua.dap... uses

But I don't think you actaully need to use v:lua to do the things you want to do. You could instead do:

let g:example_in_viml = luaeval('require("dap").do_something()')

or others. I know v:lua is a bit conveninent, but I find the global a bit confusing.

How to set up XDebug PHP on Windows?

Is there someone who managed to use XDebug on Xampp Windows?. I have executed the command :lua require('dap').continue(), but no changes have appeared. when I enter the command on REPL, the message No Active debug session appears as a result. This is the setup code that I have used:

-- PHP
  dap.adapters.php = {
    type = "executable",
    command = "node",
    args = {"C:/tools/vscode-php-debug/out/phpDebug.js"}
  }

  dap.configurations.php = {
    {
      name = "Listen for XDebug",
      type = "php",
      request = "launch",
      port = 9003
    },
}

and php.ini:

[XDebug]
zend_extension = "C:\xampp\php\ext\php_xdebug-3.0.4-7.4-vc15-x86_64.dll"
xdebug.mode=debug
xdebug.start_with_request=yes
xdebug.client_host=127.0.0.1
xdebug.client_port=9003
xdebug.remote_log = "c:\xampp\tmp\xdebug.txt"

I have checked the state of Node.js, and I found it is running. I also checked the condition of port number 9003, and I found that the port is not used by other applications.

Why shows such a mistake, ` No configuration found for c`

image

This is my configuration

⬮ lua << EOF
⬮  local dap = require 'dap'
⬮  dap.adapters.cpp = {
⬮      type = 'executable',
⬮      name = "cppdbg",
⬮      command = vim.api.nvim_get_runtime_file("gadgets/linux/vscode-cpptools/
  ↪ debugAdapters/OpenDebugAD7", false)[1],
⬮      args = {},
⬮      attach = {
⬮          pidProperty = "processId",
⬮          pidSelect = "ask"
⬮      }
⬮  }
⬮  dap.adapters.cpp = {
⬮    type = 'executable',
⬮    attach = {
⬮      pidProperty = "pid",
⬮      pidSelect = "ask"
⬮    },
⬮    command = 'lldb-vscode', -- my binary was called 'lldb-vscode-11'
⬮    env = {
⬮      LLDB_LAUNCH_FLAG_LAUNCH_IN_TTY = "YES"
⬮    },
⬮    name = "lldb"
⬮  }
⬮ EOF

I changed the wiki because rust-lldb works for me

The wiki said that rust-lldb doesn't work with lldb-vscode, but it does for me

image

My function: https://github.com/p00f/dotfiles/blob/main/nvim/.config/nvim/lua/dap_functions.lua (same as wiki but removed or "gdb" from the value of MI_MODE)
My adapter and debug configuration setup: https://github.com/p00f/dotfiles/blob/main/nvim/.config/nvim/lua/dap_setup.lua (same as wiki)
My DebugRust command: lua require 'dap_functions'.start_c_debugger({<f-args>}, 'lldb', 'rust-lldb')

Feature request: reload config before showing config

I came across this 'issue' and thought this might affect others as well.

Basically I worked around my problem like this:

init.vim:

nmap <silent> <leader>ee <cmd>luafile $HOME/.config/nvim/lua/dap_python.lua<cr>

~/.config/nvim/lua/dap_python.lua:

dap.configurations.python = {
    {
        type = 'python';
        request = 'launch';
        name = 'Regular run';
        program = gps;
        args = {'pigps_cartpole'};
        console = dap.integratedTerminal;
        pythonPath = function()
            return gps_dir..'venv_gps/bin/python'
        end;
    },
    ...

It might be very useful to support this reloading natively. Maybe I specify a file for each filetype to be reloaded. Or the configurations have to be specified in ftplugin/<lang>.vim so you only reload that?

I didn't really think this through so it might be nonsense.
Please tell me, if this explanation of my idea is too fishy.

Kind regards,
Maxim

Make signs configurable

Hi! It'd be awesome if we could change the sign symbol and highlight defined here:

https://github.com/mfussenegger/nvim-dap/blob/master/lua/dap.lua#L103-L105

vim.fn.sign_define('DapBreakpoint', {text='B', texthl='', linehl='', numhl=''})
vim.fn.sign_define('DapLogPoint', {text='L', texthl='', linehl='', numhl=''})
vim.fn.sign_define('DapStopped', {text='', texthl='', linehl='debugPC', numhl=''})

I hope I can send you a PR over the weekend but I can't promise anything right now.

Much appreciated, thank you for your time!

DAP client/server symmetry and command line interfaces

I worked on lldb and IDE integration centered around the DAP and lldb-vscode last year. One glaring problem that I found was the dap-repl (as this plugin has termed it) is very limited in functionality. e.g. it doesn't support vt220/ecma-48/man console_codes and is thus a (very) dumb terminal.

If you're a systems programmer (or any other programmer that prefers the terminal) this is a big issue since you probably learned to debug via command line interfaces. So as a systems engineer working on systems tooling for other systems engineer I wanted to properly introduce a mechanism to let the command gdb/lldb command prompt run the show and have the DAP operate more as a GUI library instead of debugger controller.

So, sorry for the long exposition, but I've had problems explaining this part to people.

What I'm aiming to do is to add extensions to the DAP to enable this to happen. As an exemplary usage flow:

(in vim) :StartDapLldbVscode

would take you to a split screen with the left side an empty buffer and the right side a neovim terminal emulator window hosting lldb's command interpreter. You type file a.out, b main, r and it starts as usual but the DAP is used more-or-less as a GUI slave that can forward user actions such as breakpoint/step/continue/evaluate requests.

The only real requirement here would be for the DAP client to acknowledge that it can support a PTY pair hosting terminal for the DAP server to attach to the PTY slave with some proper TERM var set and function as normal and then to actually offer the connection. Luckily for neovim's purposes, we can create arbitrary terminals for free and just spawn the DAP server there and inform it that this mode is supported.

For further reading, I tried submitted this idea to the DAP official repository but didn't get far. microsoft/debug-adapter-protocol#45

I mention this here because I actually just created my own project called nvim-dap about two weeks ago to tinker around with this before inadvertently seeing this mentioned on reddit. So I figured I'd check if the idea sounded interesting.

nvim-dap with Maven/Gradle projects

Hi,

first of all: Awesome tool-set! Your repos have played a major role in enabling my migration from IntelliJ IDEA to Neovim as my daily driver for Java development. Thanks for that!

I am facing one issue with nvim-dap: Everything is set up, and I can toggle breakpoints, etc.
If I understood correctly, the jdt.ls language server should auto-detect debug configurations for main files, and I should be able to launch them with: lua require'dap'.continue() from within a class that has a main method.

However, this prints the message: No configuration found for java.
Am I still missing something?

Here's the relevant excerpt from my LSP configuration:

config.on_attach = on_jdtls_attach -- setup_dap() is called on attach
config.on_init = function(client, _)
  client.notify('workspace/didChangeConfiguration', { settings = config.settings })
end
local extendedClientCapabilities = require'jdtls'.extendedClientCapabilities
extendedClientCapabilities.resolveAdditionalTextEditsSupport = true
local bundles = {
  vim.fn.glob(home .. "/git/clones/java-debug/com.microsoft.java.debug.plugin/target/com.microsoft.java.debug.plugin-*.jar")
}
vim.list_extend(bundles, vim.split(vim.fn.glob(home .. "/git/clones/vscode-java-test/server/*.jar"), "\n"))
config.init_options = {
  extendedClientCapabilities = extendedClientCapabilities;
  bundles = bundles;
}
jdtls.start_or_attach(config)

Use vim.notify to display notifications

We could use vim.notify to display notifications (neovim/neovim#13843) to enable the user to handle different notification levels (info/warning/error) in their preferred format.

I can add this feature when I have some time for some mechanical search and replace work.

nvim-dap doesn't show buffer on stop when it's opened in a background tab

When you have the buffer where nvim-dap wants to set it's stopped cursor is opened in background tab, you might not notice it. This can be very confusin. It would be better when nvim-dap would re-use a window in the current tab as it would do when the buffer had no active window with it.

nvim_tabpage_list_wins(0) instead of nvim_list_wins here https://github.com/theHamsta/nvim-dap/blob/0fa0112f0512bbaf76daa3072a422de05a7031a9/lua/dap.lua#L346-L355

I will create a PR for this.

dap.continue() using default Python configuration seems to do nothing

Thanks for what looks to be a promising plugin/hopefully an addition to core, eventually!

I've been trying to use the configuration for Python given in the docs to test this out, but unfortunately, I can't seem to start a debug session. I suspect I'm missing something about how to use this.

Specifically, with the following configuration:

local dap = require('dap')
local function get_python()
    local python_path = '/usr/bin/python'
    local virtualenv = vim.fn.getenv('VIRTUAL_ENV')
    if virtualenv ~= vim.NIL and virtualenv ~= '' then
        python_path = virtualenv .. '/bin/python'
    end

    return python_path
end

dap.adapters.python = {
    type = 'executable',
    command = get_python(),
    args = {'-m', 'debugpy.adapter'}
}

dap.configurations.python = {
    {
        type = 'python',
        request = 'launch',
        name = "Launch file",
        program = "${file}",
        pythonPath = get_python()
    }
}

running :lua require'dap'.continue() in a Python buffer doesn't seem to do anything - I neither get errors nor any indication of a debug session starting.

I've checked that running the command I specify manually - that is, running /path/to/bin/python -m debugpy.adapter - correctly starts debugpy, so I think I have the adapter installed correctly.

Am I missing something? Is this the correct way to use nvim-dap? Is there some way I can view debug logs, etc.?

Thanks!

Per project configuration / vscode/launch.json support ?

I'd like to get some opinions on whether nvim-dap should support vscode/launch.json files for debug configurations, or have some other mechanisms for users to define per-project debug configurations.

Full vscode/launch.json support is likely not feasible (it supports things like accessing editor configurations via variables). But I think a reasonable subset would be fairly easy to support - and with that the majority of the existing launch.json files would "just work".

Exit does not exit session

Currently, exit only closes the REPL instead of closing the session:

if vim.tbl_contains(M.commands.exit, text) then
api.nvim_buf_set_option(buf, 'modified', false)
api.nvim_command('close')
end

Is this intended? If yes, maybe one could provide a command to terminate the session.

REPL multiline display

I'm not sure what's causing this behavior, but numpy arrays are being displayed on a single line in the REPL:

dap_repl

This is strange, as I don't remember this being an issue. Last time I used nvim-dap, the arrays were nicely formatted in the REPL, similarly as require('dap.ui.variables').hover() when multiline_variable_display is set to true:

dap_hover

I tried resetting to previous commits, but the single line formatting is still persistent. Any idea as to what might be causing this behavior?

[feature]: autocomplete via LSP in the dap-repl

I'm unsure if I'm just being ignorant or if this is actually a missing feature...

Right now in my setup when I launch a debugger and then attach using nvim-dap inside the dap-repl I cannot get the builtin LSP to trigger. Maybe there's something wrong in my setup or my completion trigger is being stepped on but this would be really nice to have if possible. Happy to help contribute if need be.

feature-request: remote support

Hi! I am wondering if supporting a 2nd method for attaching to a running debugger process alongside ssh is on your roadmap/something you'd be willing to accept PRs for.

For a little more context Vscode allows connecting with a remote mode which I have used in the past to connect to apps running inside docker containers. The configuration json in launch.json looks something like this:

{
      "name": "service attach api_v2",
      "type": "go",
      "request": "attach",
      "mode": "remote",
      "cwd": "${workspaceFolder}/go.git",
      "remotePath": "/opt/gopath/src/github.com/go.git",
      "port": 50029,
}

and the shell script that kicks off the debugger on the remote host is something like this:

#!/bin/bash
set -e
CONTAINER=$1
TARGET_PROCESS=$2
DELVE_PORT=$3
docker exec ${CONTAINER}_1 sh -c "pkill -9 dlv; exit 0"
docker exec ${CONTAINER}_1 pgrep -n -f "$TARGET_PROCESS" | \
  xargs -I "{PID}" docker exec -d ${CONTAINER}_1 bin/delve attach {PID} --headless --listen=:$DELVE_PORT --log --api-version=2

I added support for this in vimspector but am trying to migrate to nvim-dap for first class neovim support so would definitely be willing to work on this if you were interested in accepting a PR for it. Thanks!

help setting up vscode-js-debug

vscode-js-debug is microsoft's new standard js debugger, it's standard in vs code. I've been trying to set it up, and I have the following config:

lua << EOF
	local dap = require('dap');
	dap.set_log_level('TRACE');
	dap.adapters.node = {
		type = "executable",
		name = "node-debug",
		command = "node",
		args= {"/home/abhishek/.local/share/debuggers/vscode-js-debug/out/src/debugServerMain.js", "45635" }
	}
	dap.configurations.javascript = {
		{
		type = "node",
		request = "launch",
		name = "Launch Program",
		program = "${workspaceFolder}/${file}",
		debugServer = 45635
		}
	}
EOF

when I try and run it, it gives me the following log info. Also, I'm not sure I'm setting the log level correctly, because I don't see any [TRACE] items in the logfile, how do I check what it's set to during runtime?

[ DEBUG ] 2020-12-31T04:50:23Z-0500 ] ...e/nvim/site/pack/pretentious7/start/nvim-dap/lua/dap.lua:1010 ]	"request"	{
  arguments = {
    adapterID = "nvim-dap",
    clientId = "neovim",
    clientname = "neovim",
    columnsStartAt1 = true,
    linesStartAt1 = true,
    locale = "en_IN",
    pathFormat = "path",
    supportsRunInTerminalRequest = true
  },
  command = "initialize",
  seq = 0,
  type = "request"
}

presumably it's just not responding, but how do I go about debugging this? I tested with python's debug adapter and that works fine.

Can nvim-dap add function to replace 'dap'.run_last ?

If the debugging process is not completely finished, at this time we want to restart the debugging.If the direct call to 'dap'.run_last, we may encounter strange behavior. We need to close the previous debugging process by dap.disconnect() first and then run the function dap.run_last.

Stop function does not stop session

Steps to reproduce

  1. Start any session
  2. Call lua require("dap").stop()

Expected behavior

Session stopped, the repl closed.

Current behavior

The repl and the application is still active. But any command in repl says that there i no active session.

Make StepInTarget a Separate Function

debugpy has changed its behavior to no longer just provide stepInTargets on the same line but within the whole stack frame. Maybe we should ask for stepInTargets only when the user has explicitly asked for (parameter for step_into it or offer it as a separate function.

image

Skip "Press ENTER or type command to continue"

Hi! Thank you for the awesome plugin!

I have a suggestion. Currently on dap.run(config) the plugin shows message:

изображение

Therefore, I would like to suggest adding the option to skip this message or not require confirmation by pressing Enter by default.

Feature Idea: nvim-treesitter integration

Just writing down here some ideas to evaluate whether an integration with the abstraction layer https://github.com/nvim-treesitter/nvim-treesitter or just the built-in tree-sitter might be worth considering. Treesitter can parser our files and could help with DAP's ui.

E.g.

  • Display virtual text with the current values of the locals where the locals are used in the code
  • Find current scope of frame and locals
  • Help with things like "Evaluate expression" under cursor (this might also be possible by an evaluate textobj, nvim-treesitter provides a textobj for the currently selected syntax node)

Debugging doesn't work

What's the problem?

If I place a breakpoint and start the debugger, than the breakpoint will be ignored and the script just gets executed. Here's a live demo:

Video.mp4

Steps to reproduce

This is in my init.vim:

call plug#begin('~/.vim/plugged')
Plug 'mfussenegger/nvim-dap'
Plug 'theHamsta/nvim-dap-virtual-text'
call plug#end()
source ~/.config/nvim/plugins/dap.vim

This is my ~/.config/nvim/plugin/dap.vim:

augroup NvimDap
    autocmd!
    au FileType dap-repl lua require('dap.ext.autocompl').attach()
augroup END

nnoremap <F5> :lua require('dap').continue()<CR>
nnoremap <F6> :lua require('dap').step_over()<CR>
nnoremap <F7> :lua require('dap').step_into()<CR>
nnoremap <F8> :lua require('dap').step_out()<CR>
nnoremap <F9><F9> :lua require('dap').toggle_breakpoint()<CR>
nnoremap <F9><F10> :lua require('dap').set_breakpoint(vim.fn.input('Breakpoint condition: '))<CR>
nnoremap <F9><F7> :lua require('dap').set_breakpoint(nil, nil, vim.fn.input('Log point message: '))<CR>
nnoremap <F9><F8> :lua require('dap').repl.open()<CR>
"nnoremap <silent> <leader>dl :lua require'dap'.run_last()<CR>

lua require("dap_conf")

This is my ~/.config/nvim/lua/dap_conf.lua:

local dap = require('dap')

vim.g.dap_virtual_text = true

-- request variable values for all frames (experimental)
--vim.g.dap_virtual_text = 'all frames'

dap.adapters.python = {
    type = 'executable';
    command = "/usr/bin/python";
    args = { '-m', 'debugpy.adapter'};
}

dap.configurations.python = {
    {
        type = 'python';
        request = "launch";
        name = "Launch file";
        program = "${file}";
        pythonPath = function()
            return "/usr/bin/python"
        end;
    };
}

Now if I open this file: ~/tmp.py:

print("Test")
print("Yes")

if 1 == 1:
    print("Ha")
else:
    print("No")

and go to line 4, press <F9><F9> (toggle breakpoint for me), than <F9><F10> (repl.open) and than <F5> (continue) the script finishes and ignores the breakpoint.

Have you installed the adapter?

Yes it should be installed:
image

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.