mirror of
https://github.com/kossLAN/nvim-flake.git
synced 2025-11-04 17:59:50 -05:00
dap: add dapui & add lldb-dap support
This commit is contained in:
parent
c4de9207c0
commit
3784061378
4 changed files with 67 additions and 36 deletions
12
flake.lock
generated
12
flake.lock
generated
|
|
@ -39,11 +39,11 @@
|
||||||
"systems": "systems"
|
"systems": "systems"
|
||||||
},
|
},
|
||||||
"locked": {
|
"locked": {
|
||||||
"lastModified": 1726560853,
|
"lastModified": 1731533236,
|
||||||
"narHash": "sha256-X6rJYSESBVr3hBoH0WbKE5KvhPU5bloyZ2L4K60/fPQ=",
|
"narHash": "sha256-l0KFg5HjrsfsO/JpG+r7fRrqm12kzFHyUHqHCVpMMbI=",
|
||||||
"owner": "numtide",
|
"owner": "numtide",
|
||||||
"repo": "flake-utils",
|
"repo": "flake-utils",
|
||||||
"rev": "c1dfcf08411b08f6b8615f7d8971a2bfa81d5e8a",
|
"rev": "11707dc2f618dd54ca8739b309ec4fc024de578b",
|
||||||
"type": "github"
|
"type": "github"
|
||||||
},
|
},
|
||||||
"original": {
|
"original": {
|
||||||
|
|
@ -181,11 +181,11 @@
|
||||||
},
|
},
|
||||||
"nixpkgs_2": {
|
"nixpkgs_2": {
|
||||||
"locked": {
|
"locked": {
|
||||||
"lastModified": 1730531603,
|
"lastModified": 1731676054,
|
||||||
"narHash": "sha256-Dqg6si5CqIzm87sp57j5nTaeBbWhHFaVyG7V6L8k3lY=",
|
"narHash": "sha256-OZiZ3m8SCMfh3B6bfGC/Bm4x3qc1m2SVEAlkV6iY7Yg=",
|
||||||
"owner": "NixOS",
|
"owner": "NixOS",
|
||||||
"repo": "nixpkgs",
|
"repo": "nixpkgs",
|
||||||
"rev": "7ffd9ae656aec493492b44d0ddfb28e79a1ea25d",
|
"rev": "5e4fbfb6b3de1aa2872b76d49fafc942626e2add",
|
||||||
"type": "github"
|
"type": "github"
|
||||||
},
|
},
|
||||||
"original": {
|
"original": {
|
||||||
|
|
|
||||||
|
|
@ -87,6 +87,7 @@ with final.pkgs.lib; let
|
||||||
mini-nvim # https://github.com/echasnovski/mini.nvim/
|
mini-nvim # https://github.com/echasnovski/mini.nvim/
|
||||||
# Debugging
|
# Debugging
|
||||||
nvim-dap
|
nvim-dap
|
||||||
|
nvim-dap-ui
|
||||||
# Notifications
|
# Notifications
|
||||||
nvim-notify
|
nvim-notify
|
||||||
fidget-nvim
|
fidget-nvim
|
||||||
|
|
@ -113,10 +114,6 @@ with final.pkgs.lib; let
|
||||||
rustfmt # rust formatter
|
rustfmt # rust formatter
|
||||||
prettierd # typescript/javascript formatter
|
prettierd # typescript/javascript formatter
|
||||||
# google-java-format # java formatter based off google guidelines
|
# google-java-format # java formatter based off google guidelines
|
||||||
|
|
||||||
# misc
|
|
||||||
nodejs # eww
|
|
||||||
gcc
|
|
||||||
];
|
];
|
||||||
in {
|
in {
|
||||||
# This is the neovim derivation
|
# This is the neovim derivation
|
||||||
|
|
|
||||||
|
|
@ -52,7 +52,6 @@ vim.schedule(function()
|
||||||
end)
|
end)
|
||||||
|
|
||||||
-- Configure Neovim diagnostic messages
|
-- Configure Neovim diagnostic messages
|
||||||
|
|
||||||
local function prefix_diagnostic(prefix, diagnostic)
|
local function prefix_diagnostic(prefix, diagnostic)
|
||||||
return string.format(prefix .. ' %s', diagnostic.message)
|
return string.format(prefix .. ' %s', diagnostic.message)
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -1,30 +1,65 @@
|
||||||
|
-- For some reason this nvim-dap doesn't wan't to find lldb-dap executable...
|
||||||
|
local function get_binary_path(binary)
|
||||||
|
local handle = io.popen('whereis -b ' .. binary .. ' | cut -d" " -f2')
|
||||||
|
if handle then
|
||||||
|
local result = handle:read('*a')
|
||||||
|
handle:close()
|
||||||
|
return result:gsub('\n', '') -- Remove trailing newline
|
||||||
|
end
|
||||||
|
return nil
|
||||||
|
end
|
||||||
|
|
||||||
local dap = require('dap')
|
local dap = require('dap')
|
||||||
dap.adapters.gdb = {
|
dap.adapters = {
|
||||||
type = 'executable',
|
lldb = {
|
||||||
command = 'gdb',
|
type = 'executable',
|
||||||
args = { '-i', 'dap' },
|
command = get_binary_path('lldb-dap'),
|
||||||
}
|
name = 'lldb',
|
||||||
|
},
|
||||||
dap.configurations.c = {
|
gdb = {
|
||||||
{
|
type = 'executable',
|
||||||
name = 'Launch',
|
command = 'gdb',
|
||||||
type = 'gdb',
|
args = { '-i', 'dap' },
|
||||||
request = 'launch',
|
|
||||||
program = function()
|
|
||||||
return vim.fn.input('Path to executable: ', vim.fn.getcwd() .. '/', 'file')
|
|
||||||
end,
|
|
||||||
stopAtBeginningOfMainSubprogram = false,
|
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
dap.configurations.cpp = {
|
local lldb = {
|
||||||
{
|
name = 'lldb',
|
||||||
name = 'Launch',
|
type = 'lldb',
|
||||||
type = 'gdb',
|
request = 'launch',
|
||||||
request = 'launch',
|
program = function()
|
||||||
program = function()
|
return vim.fn.input('Path to executable: ', vim.fn.getcwd() .. '/', 'file')
|
||||||
return vim.fn.input('Path to executable: ', vim.fn.getcwd() .. '/', 'file')
|
end,
|
||||||
end,
|
cwd = '${workspaceFolder}',
|
||||||
stopAtBeginningOfMainSubprogram = false,
|
stopOnEntry = false,
|
||||||
},
|
args = {},
|
||||||
|
runInTerminal = true,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
local gdb = {
|
||||||
|
name = 'gdb',
|
||||||
|
type = 'gdb',
|
||||||
|
request = 'launch',
|
||||||
|
program = function()
|
||||||
|
return vim.fn.input('Path to executable: ', vim.fn.getcwd() .. '/', 'file')
|
||||||
|
end,
|
||||||
|
cwd = '${workspaceFolder}',
|
||||||
|
}
|
||||||
|
|
||||||
|
dap.configurations.c = { lldb, gdb }
|
||||||
|
dap.configurations.cpp = { lldb, gdb }
|
||||||
|
dap.configurations.rust = lldb
|
||||||
|
|
||||||
|
-- DAP UI
|
||||||
|
local dapui = require('dapui')
|
||||||
|
dapui.setup()
|
||||||
|
|
||||||
|
dap.listeners.after.event_initialized['dapui_config'] = function()
|
||||||
|
dapui.open()
|
||||||
|
end
|
||||||
|
dap.listeners.before.event_terminated['dapui_config'] = function()
|
||||||
|
dapui.close()
|
||||||
|
end
|
||||||
|
dap.listeners.before.event_exited['dapui_config'] = function()
|
||||||
|
dapui.close()
|
||||||
|
end
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue