mfussenegger / nvim-dap Goto Github PK
View Code? Open in Web Editor NEWDebug Adapter Protocol client implementation for Neovim
License: GNU General Public License v3.0
Debug Adapter Protocol client implementation for Neovim
License: GNU General Public License v3.0
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
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
Currently, exit
only closes the REPL instead of closing the session:
Lines 62 to 65 in be30dba
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.
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.
I'm not sure what's causing this behavior, but numpy arrays are being displayed on a single line in the 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
:
I tried resetting to previous commits, but the single line formatting is still persistent. Any idea as to what might be causing this behavior?
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.
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:
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.
⬮ 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
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)
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!
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!
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.
I have a question about a spot in the code of nvim-dap
Line 287 in 0426d84
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.
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
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",
},
}
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,
},
}
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?
https://microsoft.github.io/debug-adapter-protocol/overview#debug-session-start
The DAP protocol supports multi-sessions (and e.g. JS debugger seems to be using that: microsoft/vscode-js-debug#902), does this plugin support this somehow? It's okay if there needs to be an extension as for python but I'm wondering where to start.
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.
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
.
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!
Steps to reproduce
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.
With nvim_buf_set_virtual_text() is possible to emulate the inline values for variables.
Is it possible something like that with this plugin?
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!
I am trying to use https://github.com/xdebug/vscode-php-debug
So I found that someone else added that support: https://github.com/tk-shirasaka/develop/blob/c9cccb92689b8a09fa02a6490cdf90e25dc37bf9/nvim/lua/plugin_settings/nvim-dap.lua#L26
So I added the code https://github.com/Mte90/dotfiles/blob/master/.config/nvim/lua/plugin/dap.lua
But I am able just to add a breakpoint if I try to run the continue
there is the error about No stopped thread
Hello,
I have tried to follow the examples given in the manual and I get very weird behaviour with the debugpy
adapter.
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,
}
}
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.
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?
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.
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?
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.
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".
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:
With no theme just to show it's not theme related or something:
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?
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.
To get notifications about (major) updates to nvim-dap subscribe to this issue.
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?
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.
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.
It is possible to integrate a sidebar like vista.vim https://github.com/liuchengxu/vista.vim?
In this way I can have an IDE ui like that is more easy to use to me (I don't remember often the hotkeys).
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.
The wiki said that rust-lldb
doesn't work with lldb-vscode
, but it does for me
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')
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
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)
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.
: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
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.