Add cpp debugger config

pull/2/head
Ensar Sarajčić 2022-03-23 11:40:13 +01:00
parent 13d9528d69
commit 355de23a40
2 changed files with 58 additions and 2 deletions

View File

@ -12,7 +12,8 @@ let g:ale_linters.python = ['flake8']
let g:ale_linters.kotlin = ['ktlint']
let g:ale_linters.clojure = []
let g:ale_linters.cs = ['OmniSharp']
let g:ale_linters.cpp = ['clangd']
let g:ale_linters.cpp = ['clang']
let g:ale_linters.c = g:ale_linters.cpp
" ALE Fixers configuration
let g:ale_fixers = {}
@ -22,6 +23,7 @@ let g:ale_fixers.dart = ['dartfmt']
let g:ale_fixers.lua = ['luafmt']
let g:ale_fixers.go = ['gofmt']
let g:ale_fixers.cpp = ['clang-format', 'clangtidy']
let g:ale_fixers.c = g:ale_fixers.cpp
let g:ale_fixers.cmake = ['cmakeformat']
let g:ale_fixers.java = ['google_java_format']
let g:ale_fixers.rust = ['rustfmt']

View File

@ -29,7 +29,8 @@ set_keymap("n", "<Leader>dsi", "<cmd>lua require'dap'.step_into()<CR>", default_
set_keymap("n", "<Leader>dro", "<cmd>lua require'dap'.open()<CR>", default_opts)
-- Nvim DAP UI
require("dapui").setup()
local dapui = require("dapui")
dapui.setup()
-- Debugger Hover map
local api = vim.api
@ -53,3 +54,56 @@ dap.listeners.after["event_terminated"]["me"] = function()
end
keymap_restore = {}
end
-- Additional servers
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 = {},
-- 💀
-- if you change `runInTerminal` to true, you might need to change the yama/ptrace_scope setting:
--
-- echo 0 | sudo tee /proc/sys/kernel/yama/ptrace_scope
--
-- Otherwise you might get the following error:
--
-- Error on launch: Failed to attach to the target process
--
-- But you should be aware of the implications:
-- https://www.kernel.org/doc/html/latest/admin-guide/LSM/Yama.html
runInTerminal = false,
-- 💀
-- If you use `runInTerminal = true` and resize the terminal window,
-- lldb-vscode will receive a `SIGWINCH` signal which can cause problems
-- To avoid that uncomment the following option
-- See https://github.com/mfussenegger/nvim-dap/issues/236#issuecomment-1066306073
postRunCommands = {"process handle -p true -s false -n false SIGWINCH"}
}
}
dap.configurations.c = dap.configurations.cpp
dap.configurations.rust = dap.configurations.cpp
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