1+ -- Explore:
2+ -- - External terminal
3+ -- - make the virt lines thing available if ppl want it
4+ -- - find the nearest codelens above cursor
5+
16local has_dap , dap = pcall (require , " dap" )
27if not has_dap then
38 return
49end
510
6- dap .set_log_level " TRACE"
11+ require (" nvim-dap-virtual-text" ).setup {
12+ enabled = true ,
13+
14+ -- DapVirtualTextEnable, DapVirtualTextDisable, DapVirtualTextToggle, DapVirtualTextForceRefresh
15+ enabled_commands = false ,
16+
17+ -- highlight changed values with NvimDapVirtualTextChanged, else always NvimDapVirtualText
18+ highlight_changed_variables = true ,
19+ highlight_new_as_changed = true ,
20+
21+ -- prefix virtual text with comment string
22+ commented = false ,
23+
24+ show_stop_reason = true ,
25+
26+ -- experimental features:
27+ virt_text_pos = " eol" , -- position of virtual text, see `:h nvim_buf_set_extmark()`
28+ all_frames = false , -- show virtual text for all stack frames not only current. Only works for debugpy on my machine.
29+ }
730
831-- TODO: How does terminal work?
932dap .defaults .fallback .external_terminal = {
1033 command = " /home/tjdevries/.local/bin/kitty" ,
1134 args = { " -e" },
1235}
1336
37+ dap .adapters .nlua = function (callback , config )
38+ callback { type = " server" , host = config .host , port = config .port }
39+ end
40+
1441dap .configurations .lua = {
1542 {
1643 type = " nlua" ,
@@ -28,25 +55,6 @@ dap.configurations.lua = {
2855 },
2956}
3057
31- dap .adapters .nlua = function (callback , config )
32- callback { type = " server" , host = config .host , port = config .port }
33- end
34-
35- vim .g .dap_virtual_text = true
36-
37- -- dap.adapters.cpp = {
38- -- type = 'executable',
39- -- attach = {
40- -- pidProperty = "pid",
41- -- pidSelect = "ask"
42- -- },
43- -- command = 'lldb-vscode-11',
44- -- env = {
45- -- LLDB_LAUNCH_FLAG_LAUNCH_IN_TTY = "YES"
46- -- },
47- -- name = "lldb"
48- -- }
49-
5058dap .adapters .c = {
5159 name = " lldb" ,
5260
@@ -175,6 +183,26 @@ dap.configurations.c = {
175183 cwd = vim .fn .expand " ~/build/neovim" ,
176184 gdbpath = vim .fn .exepath " gdb" ,
177185 },
186+ -- {
187+ -- name = "Launch rust-analyzer lsif",
188+ -- type = "lldb",
189+ -- request = "launch",
190+ -- program = "/home/tjdevries/sourcegraph/rust-analyzer.git/monikers-1/target/debug/rust-analyzer",
191+ -- args = { "lsif", "/home/tjdevries/build/rmpv/" },
192+ -- cwd = "/home/tjdevries/sourcegraph/rust-analyzer.git/monikers-1/",
193+ -- stopOnEntry = false,
194+ -- runInTerminal = false,
195+ -- },
196+ {
197+ name = " Launch ./build/bin/nvim" ,
198+ type = " lldb" ,
199+ request = " launch" ,
200+ program = " /home/tjdevries/build/neovim.git/lua_autocmd/build/bin/nvim" ,
201+ args = { " --headless" },
202+ cwd = " /home/tjdevries/build/neovim.git/lua_autocmd/" ,
203+ stopOnEntry = false ,
204+ runInTerminal = false ,
205+ },
178206}
179207
180208-- https://github.com/mfussenegger/nvim-dap/wiki/Debug-Adapter-installation#go-using-delve-directly
@@ -317,7 +345,7 @@ require("dap-python").setup("python", {
317345
318346dap .adapters .lldb = {
319347 type = " executable" ,
320- command = " /usr/bin/lldb-vscode-12 " ,
348+ command = " /usr/bin/lldb-vscode-11 " ,
321349 name = " lldb" ,
322350}
323351
@@ -391,64 +419,6 @@ dap.adapters.rt_lldb = function(callback, _)
391419 end )
392420end
393421
394- -- function M.setup_adapter()
395- -- local dap = require("dap")
396- -- dap.adapters.rt_lldb = config.options.dap.adapter
397- -- end
398-
399- function StartRustServer (args )
400- args = args or {}
401-
402- if not pcall (require , " dap" ) then
403- vim .notify " nvim-dap not found."
404- return
405- end
406-
407- if not pcall (require , " plenary.job" ) then
408- vim .notify " plenary not found."
409- return
410- end
411-
412- local Job = require " plenary.job"
413-
414- -- local cargo_args = get_cargo_args_from_runnables_args(args)
415-
416- vim .notify " Compiling a debug build for debugging. This might take some time..."
417-
418- Job
419- :new ({
420- command = " cargo" ,
421- args = { " build" , " --message-format=json" },
422- cwd = nil ,
423- on_exit = function (j , code )
424- if code and code > 0 then
425- vim .notify " An error occured while compiling. Please fix all compilation issues and try again."
426- end
427- vim .schedule (function ()
428- for _ , value in pairs (j :result ()) do
429- local json = vim .fn .json_decode (value )
430- if type (json ) == " table" and json .executable ~= vim .NIL and json .executable ~= nil then
431- local dap_config = {
432- name = " Rust tools debug" ,
433- type = " rt_lldb" ,
434- request = " launch" ,
435- program = json .executable ,
436- args = args .executableArgs or { " lsif" , " /home/tjdevries/build/rmpv/" },
437- cwd = args .workspaceRoot ,
438- stopOnEntry = false ,
439- runInTerminal = false ,
440- }
441- dap .run (dap_config )
442-
443- break
444- end
445- end
446- end )
447- end ,
448- })
449- :start ()
450- end
451-
452422dap .configurations .rust = {
453423 {
454424 name = " Launch" ,
@@ -485,6 +455,15 @@ dap.configurations.rust = {
485455 },
486456}
487457
458+ vim .keymap .set (" n" , " <leader><F5>" , function ()
459+ if vim .bo .filetype ~= " rust" then
460+ vim .notify " This wasn't rust. I don't know what to do"
461+ return
462+ end
463+
464+ R (" tj.dap" ).select_rust_runnable ()
465+ end )
466+
488467vim .cmd [[ nnoremap <silent> <F5> :lua require'dap'.continue()<CR>]]
489468vim .cmd [[ nnoremap <silent> <F1> :lua require'dap'.step_into()<CR>]]
490469vim .cmd [[ nnoremap <silent> <F10> :lua require'dap'.step_over()<CR>]]
0 commit comments