Update the dap mappings, add lsp indicator in bar, use default dapui
layout
This commit is contained in:
parent
de3c53c461
commit
533d663e87
4 changed files with 131 additions and 36 deletions
|
|
@ -4,14 +4,34 @@ local dap = require("dap")
|
|||
-- name = "Launch",
|
||||
-- type = "gdb",
|
||||
-- request = "launch",
|
||||
-- program = function()
|
||||
-- return vim.fn.input('Path to executable: ', vim.fn.getcwd() .. '/', 'file')
|
||||
-- end,
|
||||
-- -- program = function()
|
||||
-- -- return vim.fn.input('Path to executable: ', vim.fn.getcwd() .. '/', 'file')
|
||||
-- -- end,
|
||||
-- cwd = "${workspaceFolder}",
|
||||
-- },
|
||||
-- }
|
||||
--
|
||||
-- dap.configurations.cpp = {
|
||||
-- {
|
||||
-- name = "Launch file",
|
||||
-- type = "cppdbg",
|
||||
-- request = "launch",
|
||||
-- program = function()
|
||||
-- return vim.fn.input('Path to executable: ', vim.fn.getcwd() .. '/', 'file')
|
||||
-- end,
|
||||
-- cwd = '${workspaceFolder}',
|
||||
-- stopAtEntry = true,
|
||||
-- }
|
||||
-- }
|
||||
|
||||
dap.adapters.cppdbg = {
|
||||
id = 'cppdbg',
|
||||
type = 'executable',
|
||||
command = '/nix/store/gwags66qlqr6qmblwp0v6crkb6ca2qr1-vscode-extension-ms-vscode-cpptools-1.22.2/share/vscode/extensions/ms-vscode.cpptools/debugAdapters/bin/OpenDebugAD7',
|
||||
cwd = "${workspaceFolder}",
|
||||
}
|
||||
|
||||
dap.adapters.gdb = {
|
||||
type = "executable",
|
||||
command = "gdb",
|
||||
args = { "-i", "dap" },
|
||||
|
|
@ -54,7 +74,18 @@ end
|
|||
require('dap.ext.vscode').load_launchjs("dap_config.json", {
|
||||
cppdbg = { 'c', 'cpp' },
|
||||
lldb = { 'c', 'cpp' },
|
||||
gdb = { 'c', 'cpp' },
|
||||
debugpy = { 'python' }
|
||||
})
|
||||
|
||||
dap.set_log_level("TRACE")
|
||||
|
||||
-- require("telescope").load_extension("dap")
|
||||
-- Interface Setup
|
||||
vim.fn.sign_define('DapBreakpoint', { text='', texthl='red'})
|
||||
vim.fn.sign_define('DapBreakpointCondition', { text='', texthl='blue'})
|
||||
vim.fn.sign_define('DapBreakpointRejected', { text='', texthl='orange'})
|
||||
vim.fn.sign_define('DapStopped', { text='', texthl='green'})
|
||||
vim.fn.sign_define('DapLogPoint', { text='.>', texthl='yellow', linehl='DapBreakpoint', numhl='DapBreakpoint' })
|
||||
|
||||
vim.api.nvim_command 'autocmd FileType dap-float nnoremap <buffer><silent> q <cmd>close!<CR>'
|
||||
|
|
|
|||
|
|
@ -28,7 +28,14 @@ local opts = {
|
|||
-- cond = require("noice").api.status.mode.has,
|
||||
-- },
|
||||
},
|
||||
lualine_x = { 'diagnostics', 'filetype' },
|
||||
lualine_x = {
|
||||
function()
|
||||
-- invoke `progress` here.
|
||||
return require('lsp-progress').progress()
|
||||
end,
|
||||
'diagnostics',
|
||||
'filetype',
|
||||
},
|
||||
lualine_y = { 'progress' },
|
||||
lualine_z = { 'location' }
|
||||
},
|
||||
|
|
|
|||
|
|
@ -87,6 +87,8 @@ vim.api.nvim_create_autocmd('LspAttach', {
|
|||
vim.keymap.set({ 'n', 'v' }, '<leader>ca', vim.lsp.buf.code_action, opts)
|
||||
vim.keymap.set('n', 'gr', telescope.lsp_references, opts)
|
||||
vim.keymap.set({ 'n', 'v' }, '<leader>fm', ":Format<cr>", opts)
|
||||
vim.keymap.set('n', '<MiddleMouse>', '<LeftMouse> :lua vim.lsp.buf.definition()<cr>', opts)
|
||||
vim.keymap.set('n', '<RightMouse>', '<LeftMouse> :lua vim.lsp.buf.hover()<cr>', opts)
|
||||
end,
|
||||
})
|
||||
|
||||
|
|
@ -124,6 +126,14 @@ local dap_sb_session = dap_widgets.sidebar(dap_widgets.sessions)
|
|||
local dap_sb_threads = dap_widgets.sidebar(dap_widgets.threads)
|
||||
|
||||
vim.keymap.set('n', '<leader>b', dap.toggle_breakpoint, { desc = "Toggle breakpoint" })
|
||||
vim.keymap.set('n', '<leader>B',
|
||||
function ()
|
||||
local condition = vim.fn.input("Condition: ", "")
|
||||
dap.set_breakpoint(condition)
|
||||
end
|
||||
, { desc = "Add conditional breakpoint" })
|
||||
|
||||
local dapui = require("dapui")
|
||||
|
||||
local Hydra = require("hydra")
|
||||
Hydra({
|
||||
|
|
@ -133,10 +143,12 @@ Hydra({
|
|||
color = "pink",
|
||||
invoke_on_body = true,
|
||||
on_enter = function()
|
||||
dapui.open()
|
||||
dap.continue()
|
||||
-- dap.repl.open()
|
||||
end,
|
||||
on_exit = function()
|
||||
dapui.close()
|
||||
dap.terminate()
|
||||
dap_sb_frames.close()
|
||||
dap_sb_scopes.close()
|
||||
|
|
@ -145,27 +157,27 @@ Hydra({
|
|||
dap.repl.close()
|
||||
end,
|
||||
hint = {
|
||||
type = "window",
|
||||
type = "statusline",
|
||||
},
|
||||
},
|
||||
mode = 'n',
|
||||
body = '<leader>g',
|
||||
mode = { 'n', 'v' },
|
||||
body = '<leader>gg',
|
||||
heads = {
|
||||
{ 'c', dap.continue, { desc = "Continue" } },
|
||||
{ 'r', dap.restart, { desc = "Restart" } },
|
||||
-- { 'i', dap.pause, { desc = "Pause" } },
|
||||
{ 'I', nil, {} },
|
||||
{ 's', dap.step_into, { desc = "Step into" } },
|
||||
{ 'a', dap.step_over, { desc = "Step over" } },
|
||||
{ 'A', dap.step_out, { desc = "Step out" } },
|
||||
{ 'x', dap.repl.toggle, { desc = "repl" } },
|
||||
{ 't', dap_sb_threads.toggle, { desc = "Threads" } },
|
||||
{ 'f', dap_sb_frames.toggle, { desc = "Frames" } },
|
||||
{ 'v', dap_sb_scopes.toggle, { desc = "Scopes" } },
|
||||
-- { 'z', dap_sb_session.toggle, { desc = "Session" } },
|
||||
{ 'K', dap_widgets.hover, { desc = "Hover" } },
|
||||
{ 'D', dap.up, { desc = "Up" } },
|
||||
{ 'd', dap.down, { desc = "Down" } },
|
||||
{ '<f5>', dap.continue, { desc = "Continue" } },
|
||||
{ '<f4>', dap.restart, { desc = "Restart" } },
|
||||
{ '<f6>', dap.step_into, { desc = "Step into" } },
|
||||
{ '<f7>', dap.step_over, { desc = "Step over" } },
|
||||
{ '<f8>', dap.step_out, { desc = "Step out" } },
|
||||
{ '<f9>', dap.run_to_cursor, { desc = "Run to cursor" } },
|
||||
{ '<f10>', dap.step_back, { desc = "Step back" } },
|
||||
{ 'K', require("dapui").eval, { desc = "Hover" } },
|
||||
{ '<A-j>', dap.up, { desc = "Up" } },
|
||||
{ '<A-k>', dap.down, { desc = "Down" } },
|
||||
-- right click to eval
|
||||
{ '<rightmouse>', dapui.eval, { desc = "Eval", mode = "v" } },
|
||||
{ '<rightmouse>', '<LeftMouse> :lua require("dapui").eval()<cr>', {
|
||||
desc = "Eval",
|
||||
} },
|
||||
{ 'q', nil, { exit = true, nowait = true, desc = 'Exit' } },
|
||||
}
|
||||
})
|
||||
|
|
|
|||
|
|
@ -72,11 +72,11 @@ local plugins = {
|
|||
HopNextKey = { bg = C.text, fg = C.base, style = { "bold", "underline" } },
|
||||
HopNextKey1 = { bg = C.text, fg = C.base, style = { "bold" } },
|
||||
HopNextKey2 = { bg = C.text, fg = C.base, style = { "bold", "italic" } },
|
||||
DiagnosticUnderlineError = { style = { "undercurl" }},
|
||||
DiagnosticUnderlineWarn = { style = { "undercurl" }},
|
||||
DiagnosticUnderlineInfo = { style = { "undercurl" }},
|
||||
DiagnosticUnderlineHint = { style = { "undercurl" }},
|
||||
DiagnosticUnderlineOk = { style = { "undercurl" }},
|
||||
DiagnosticUnderlineError = { style = { "undercurl" } },
|
||||
DiagnosticUnderlineWarn = { style = { "undercurl" } },
|
||||
DiagnosticUnderlineInfo = { style = { "undercurl" } },
|
||||
DiagnosticUnderlineHint = { style = { "undercurl" } },
|
||||
DiagnosticUnderlineOk = { style = { "undercurl" } },
|
||||
-- Function = { fg = C.blue, style = { "bold" } },
|
||||
-- Keyword = { fg = C.black, style = { "italic" } },
|
||||
}
|
||||
|
|
@ -231,12 +231,38 @@ local plugins = {
|
|||
},
|
||||
{
|
||||
"rmagatti/auto-session",
|
||||
dependencies = {
|
||||
"niuiic/dap-utils.nvim",
|
||||
dependencies = {
|
||||
"niuiic/core.nvim",
|
||||
"mfussenegger/nvim-dap",
|
||||
"rcarriga/nvim-dap-ui",
|
||||
"nvim-telescope/telescope.nvim",
|
||||
}
|
||||
},
|
||||
config = function()
|
||||
require("auto-session").setup({
|
||||
log_level = "error",
|
||||
pre_save_cmds = {
|
||||
function()
|
||||
require("dap-utils").store_breakpoints("./.breakpoints")
|
||||
end
|
||||
},
|
||||
post_restore_cmds = {
|
||||
function()
|
||||
require("dap-utils").restore_breakpoints("./.breakpoints")
|
||||
end
|
||||
},
|
||||
pre_delete_cmds = {
|
||||
},
|
||||
})
|
||||
end,
|
||||
},
|
||||
-- {
|
||||
-- 'niuiic/multiple-session.nvim',
|
||||
-- dependencies = { 'niuiic/core.nvim' },
|
||||
-- config = function () require("multiple-session").setup() end
|
||||
-- },
|
||||
-- Lua
|
||||
-- {
|
||||
-- "olimorris/persisted.nvim",
|
||||
|
|
@ -492,20 +518,31 @@ local plugins = {
|
|||
}
|
||||
},
|
||||
},
|
||||
-- {
|
||||
-- "rcarriga/nvim-dap-ui",
|
||||
-- dependencies = { "mfussenegger/nvim-dap", "nvim-neotest/nvim-nio" },
|
||||
-- config = function()
|
||||
-- require("configs.dap")
|
||||
-- require("dapui").setup()
|
||||
-- end
|
||||
-- },
|
||||
{
|
||||
"rcarriga/nvim-dap-ui",
|
||||
dependencies = { "mfussenegger/nvim-dap", "nvim-neotest/nvim-nio" },
|
||||
config = function()
|
||||
require("dapui").setup()
|
||||
end
|
||||
},
|
||||
{
|
||||
"mfussenegger/nvim-dap",
|
||||
config = function()
|
||||
require("configs.dap")
|
||||
end
|
||||
},
|
||||
{ "nvim-neotest/nvim-nio" },
|
||||
{
|
||||
'linrongbin16/lsp-progress.nvim',
|
||||
config = function()
|
||||
require('lsp-progress').setup()
|
||||
end
|
||||
},
|
||||
{
|
||||
"theHamsta/nvim-dap-virtual-text",
|
||||
lazy = false,
|
||||
dependencies = { "mfussenegger/nvim-dap", "nvim-treesitter/nvim-treesitter" },
|
||||
config = function()
|
||||
require("configs.dap")
|
||||
require("nvim-dap-virtual-text").setup()
|
||||
end
|
||||
},
|
||||
|
|
@ -594,6 +631,14 @@ local plugins = {
|
|||
config = function()
|
||||
require 'treesitter-context'.setup {}
|
||||
end
|
||||
},
|
||||
{
|
||||
'Weissle/persistent-breakpoints.nvim',
|
||||
config = function()
|
||||
require('persistent-breakpoints').setup {
|
||||
load_breakpoints_event = { "BufReadPost" }
|
||||
}
|
||||
end
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue