nvim: add DAP

This commit is contained in:
tastytea 2022-08-28 20:30:59 +02:00
parent 0d4551a2d4
commit 56bb5c8248
Signed by: tastytea
SSH Key Fingerprint: SHA256:FBkvrOlhq5use1XEttyUGT4bUTDVA1ar9SgIc9P03cM
3 changed files with 72 additions and 0 deletions

View File

@ -88,3 +88,57 @@ for type, icon in pairs(signs) do
local hl = "DiagnosticSign" .. type local hl = "DiagnosticSign" .. type
vim.fn.sign_define(hl, { text = icon, texthl = hl, numhl = hl }) vim.fn.sign_define(hl, { text = icon, texthl = hl, numhl = hl })
end end
local dap = require('dap')
if vim.fn.executable('lldb-vscode') > 0 then
dap.adapters.lldb = {
type = 'executable',
command = 'lldb-vscode',
name = 'lldb'
}
dap.configurations.cpp = {
{
name = 'Launch',
type = 'lldb',
request = 'launch',
program = function()
return vim.fn.input('Path to executable: ',
vim.fn.getcwd() .. '/', 'file')
end,
cwd = '${workspaceFolder}',
stopOnEntry = false,
args = {},
},
{
name = "Attach to process",
type = 'lldb',
request = 'attach',
pid = require('dap.utils').pick_process,
args = {},
}
}
dap.configurations.c = dap.configurations.cpp
end
map('n', '<Leader>dc', dap.continue, 'Continue')
map('n', '<F10>', dap.step_over, 'DAP: step over')
map('n', '<F11>', dap.step_into, 'DAP: step into')
map('n', '<F12>', dap.step_out, 'DAP: step out')
map('n', '<Leader>db', dap.toggle_breakpoint, 'Toggle breakpoint')
map('n', '<Leader>dB', function()
dap.set_breakpoint(vim.fn.input('Breakpoint condition: '))
end, 'Set breakpoint')
map('n', '<Leader>dr', dap.repl.open, 'Open REPL')
map('n', '<Leader>dl', dap.run_last, 'Run last')
map('n', '<Leader>dj', function()
require('dap.ext.vscode').load_launchjs(
vim.fn.input('Path to launch.json: ',
vim.fn.getcwd() .. '/launch.json', 'file'))
end, 'Load launch.json')
require('dapui').setup({})
map('n', '<Leader>du', require("dapui").toggle, 'Toggle UI')
require('nvim-dap-virtual-text').setup({})

View File

@ -134,6 +134,23 @@ require('packer').startup({ function(use)
use { -- <https://github.com/ahmedkhalf/project.nvim/pull/89> use { -- <https://github.com/ahmedkhalf/project.nvim/pull/89>
'https://github.com/tastytea/project.nvim', 'https://github.com/tastytea/project.nvim',
branch = 'fallback_current_dir' } branch = 'fallback_current_dir' }
use {
'https://github.com/mfussenegger/nvim-dap',
tag = '*'
}
use {
'https://github.com/rcarriga/nvim-dap-ui',
tag = '*',
requires = 'https://github.com/mfussenegger/nvim-dap'
}
use {
'https://github.com/nvim-telescope/telescope-dap.nvim',
requires = 'https://github.com/mfussenegger/nvim-dap'
}
use {
'https://github.com/theHamsta/nvim-dap-virtual-text',
requires = 'https://github.com/mfussenegger/nvim-dap'
}
-- net -- net
use { -- embed nvim in browsers use { -- embed nvim in browsers

View File

@ -6,6 +6,7 @@ local map = require('my.functions').map
local telescope = require('telescope') local telescope = require('telescope')
local t_actions = require('telescope.actions') local t_actions = require('telescope.actions')
telescope.load_extension('projects') telescope.load_extension('projects')
telescope.load_extension('dap')
require('telescope').setup { require('telescope').setup {
mappings = { mappings = {