aboutsummaryrefslogtreecommitdiff
path: root/lua/plugins
diff options
context:
space:
mode:
Diffstat (limited to 'lua/plugins')
-rw-r--r--lua/plugins/dap.lua181
1 files changed, 149 insertions, 32 deletions
diff --git a/lua/plugins/dap.lua b/lua/plugins/dap.lua
index 9b790d9..a3e40df 100644
--- a/lua/plugins/dap.lua
+++ b/lua/plugins/dap.lua
@@ -1,8 +1,8 @@
local dap = require('dap')
-dap.defaults.fallback.external_terminal = {
- command = '/usr/bin/wezterm';
- args = {'-e'};
-}
+--dap.defaults.fallback.external_terminal = {
+-- command = '/usr/bin/wezterm';
+-- args = {'-e'};
+--}
--dap.adapters.lldb = {
-- type = 'executable',
-- --command = '/usr/bin/lldb-vscode', -- adjust as needed, must be absolute path
@@ -48,11 +48,11 @@ dap.adapters.cppdbg = {
dap.adapters.codelldb = {
type = 'server',
port = '${port}',
+ --host = "localhost",
--host = '127.0.0.1',
--port = 13000, -- 💀 Use the port printed out or specified with `--port`
executable = {
--command = os.getenv("HOME") .. '/apps/codelldb/extension/adapter/codelldb',
- --command = vim.env.HOME .. "/.vscode-oss/extensions/vadimcn.vscode-lldb-1.9.0-universal/adapter/codelldb",
command = os.getenv("HOME") .. "/.vscode-oss/extensions/vadimcn.vscode-lldb-1.9.0-universal/adapter/codelldb",
args = {'--port', '${port}'},
},
@@ -67,6 +67,7 @@ dap.adapters.lldb = {
dap.configurations.cpp = {
{
name = "Launch file",
+ --type = "lldb",
--type = "cppdbg",
type = "codelldb",
request = "launch",
@@ -74,12 +75,33 @@ dap.configurations.cpp = {
--processId = function()
-- return tonumber(vim.fn.input({ prompt = "Pid: "}))
--end,
+ cwd = '${workspaceFolder}',
program = function()
return vim.fn.input('Path to executable: ', vim.fn.getcwd() .. '/', 'file')
end,
+ --program = function()
+ -- -- First, check if exists CMakeLists.txt
+ -- local cwd = vim.fn.getcwd()
+ -- if (file.exists(cwd, "CMakeLists.txt")) then
+ -- -- Todo. Then invoke cmake commands
+ -- -- Then ask user to provide execute file
+ -- return vim.fn.input("Path to executable: ", vim.fn.getcwd() .. "/", "file")
+ -- else
+ -- local fileName = vim.fn.expand("%:t:r")
+ -- if (not file.exists(cwd, "bin")) then
+ -- -- create this directory
+ -- os.execute("mkdir " .. "bin")
+ -- end
+ -- local cmd = "!gcc -g % -o bin/" .. fileName
+ -- -- First, compile it
+ -- vim.cmd(cmd)
+ -- -- Then, return it
+ -- return "${fileDirname}/bin/" .. fileName
+ -- end
+ --end,
stopAtEntry = true,
args = {},
- runInTerminal = true,
+ --runInTerminal = true,
--runInTerminal = false,
--console = 'integratedTerminal',
@@ -95,7 +117,6 @@ dap.configurations.cpp = {
-- ignoreFailures = false
-- }
--},
- cwd = '${workspaceFolder}',
},
}
-- dap.adapters.cppdbg = {
@@ -201,42 +222,107 @@ dap.configurations.python = {
},
}
-local dapui = require('dapui')
+--local dapui = require('dapui')
+local dap_ui_status_ok, dapui = pcall(require, "dapui")
+if not dap_ui_status_ok then
+ return
+end
-- setup repl
-dap.repl.commands = vim.tbl_extend('force', dap.repl.commands, {
- exit = { 'q', 'exit' },
- custom_commands = {
- ['.run_to_cursor'] = dap.run_to_cursor,
- ['.restart'] = dap.run_last
- }
+--dap.repl.commands = vim.tbl_extend('force', dap.repl.commands, {
+-- exit = { 'q', 'exit' },
+-- custom_commands = {
+-- ['.run_to_cursor'] = dap.run_to_cursor,
+-- ['.restart'] = dap.run_last
+-- }
+--})
+
+dapui.setup({
+ layouts = {
+ {
+ elements = {
+ "watches",
+ },
+ size = 0.2,
+ position = "left",
+ },
+ },
+ controls = {
+ enabled = false,
+ },
+ render = {
+ max_value_lines = 3,
+ },
+ floating = {
+ max_height = nil, -- These can be integers or a float between 0 and 1.
+ max_width = nil, -- Floats will be treated as percentage of your screen.
+ border = "single", -- Border style. Can be "single", "double" or "rounded"
+ mappings = {
+ close = { "q", "<Esc>" },
+ },
+ },
})
-- setup dapui
dapui.setup({
- mappings = {
- expand = "<CR>",
- open = "o",
- remove = "D",
- edit = "e",
- repl = "r",
- toggle = "t",
+ mappings = {
+ expand = "<CR>",
+ open = "o",
+ remove = "D",
+ edit = "e",
+ repl = "r",
+ toggle = "t",
+ },
+ controls = {
+ enabled = false,
+ },
+ layouts = {
+ {
+ elements = {
+ { id = "scopes", size = 0.5 },
+ { id = "watches", size = 0.5 },
+ },
+ size = 40,
+ position = "left",
},
- layouts = {
- { elements = { "scopes", "breakpoints", "stacks" }, size = 0.33, position = "right" },
- { elements = { "repl", "watches" }, size = 0.27, position = "bottom" },
+ {
+ elements = { "console", "repl" },
+ position = "bottom",
+ size = 15,
},
- icons = { expanded = "-", collapsed = "$" },
- --controls = { enabled = false },
- floating = { border = "rounded", mappings = { close = { "q", "<esc>", "<c-o>" } } },
+ },
+ render = {
+ max_value_lines = 3,
+ },
+ floating = {
+ max_height = nil, -- These can be integers or a float between 0 and 1.
+ max_width = nil, -- Floats will be treated as percentage of your screen.
+ border = "single", -- Border style. Can be "single", "double" or "rounded"
+ mappings = {
+ close = { "q", "<Esc>" },
+ },
+ },
+ --icons = { expanded = "-", collapsed = "$" },
+ icons = {
+ expanded = "",
+ collapsed = "",
+ current_frame = "",
+ },
})
-- signs
-vim.fn.sign_define("DapStopped", { text = '=>', texthl = 'DiagnosticWarn', numhl = 'DiagnosticWarn' })
-vim.fn.sign_define("DapBreakpoint", { text = '<>', texthl = 'DiagnosticInfo', numhl = 'DiagnosticInfo' })
-vim.fn.sign_define("DapBreakpointRejected", { text = '!>', texthl = 'DiagnosticError', numhl = 'DiagnosticError' })
-vim.fn.sign_define("DapBreakpointCondition", { text = '?>', texthl = 'DiagnosticInfo', numhl = 'DiagnosticInfo' })
-vim.fn.sign_define("DapLogPoint", { text = '.>', texthl = 'DiagnosticInfo', numhl = 'DiagnosticInfo' })
+local sign = vim.fn.sign_define
+sign("DapBreakpoint", { text = "●", texthl = "DapBreakpoint", linehl = "", numhl = "" })
+sign('DapStopped', { text = '', texthl = 'DiagnosticSignHint', numbhl = '', linehl = '' })
+sign("DapBreakpointRejected", { text = '!>', texthl = 'DiagnosticError', numhl = 'DiagnosticError' })
+sign("DapBreakpointCondition", { text = "●", texthl = "DapBreakpointCondition", linehl = "", numhl = "" })
+sign("DapLogPoint", { text = "◆", texthl = "DapLogPoint", linehl = "", numhl = "" })
+
+--sign('DapBreakpoint', { text = '', texthl = 'DiagnosticSignError', numbhl = '', linehl = '' })
+--sign("DapLogPoint", { text = '.>', texthl = 'DiagnosticInfo', numhl = 'DiagnosticInfo' })
+--vim.fn.sign_define("DapBreakpointCondition", { text = '?>', texthl = 'DiagnosticInfo', numhl = 'DiagnosticInfo' })
+--vim.fn.sign_define("DapStopped", { text = '=>', texthl = 'DiagnosticWarn', numhl = 'DiagnosticWarn' })
+--vim.fn.sign_define("DapBreakpoint", { text = '<>', texthl = 'DiagnosticInfo', numhl = 'DiagnosticInfo' })
dap.listeners.after.event_initialized["dapui_config"] = function()
dapui.open()
@@ -247,7 +333,38 @@ end
dap.listeners.before.event_exited["dapui_config"] = function()
dapui.close()
end
+dap.listeners.before.disconnect["dapui_config"] = function()
+ dapui.close()
+end
+
+local dap_virtual_text_status_ok, dap_virtual_text_status = pcall(require, "nvim-dap-virtual-text")
+if not dap_virtual_text_status_ok then
+ return
+end
+--require("nvim-dap-virtual-text").setup()
+
+dap_virtual_text_status.setup({
+ enabled = true, -- enable this plugin (the default)
+ enabled_commands = true, -- create commands DapVirtualTextEnable, DapVirtualTextDisable, DapVirtualTextToggle, (DapVirtualTextForceRefresh for refreshing when debug adapter did not notify its termination)
+ highlight_changed_variables = true, -- highlight changed values with NvimDapVirtualTextChanged, else always NvimDapVirtualText
+ highlight_new_as_changed = false, -- highlight new variables in the same way as changed variables (if highlight_changed_variables)
+ show_stop_reason = true, -- show stop reason when stopped for exceptions
+ commented = true, -- prefix virtual text with comment string
+ only_first_definition = true, -- only show virtual text at first definition (if there are multiple)
+ all_references = false, -- show virtual text on all all references of the variable (not only definitions)
+ filter_references_pattern = "<module", -- filter references (not definitions) pattern when all_references is activated (Lua gmatch pattern, default filters out Python modules)
+ -- experimental features:
+ virt_text_pos = "eol", -- position of virtual text, see `:h nvim_buf_set_extmark()`
+ all_frames = false, -- show virtual text for all stack frames not only current. Only works for debugpy on my machine.
+ virt_lines = false, -- show virtual lines instead of virtual text (will flicker!)
+ virt_text_win_col = nil -- position the virtual text at a fixed window column (starting from the first text column) ,
+ -- e.g. 80 to position at column 80, see `:h nvim_buf_set_extmark()`
+})
+vim.cmd([[
+ autocmd TermClose * if !v:event.status | exe 'bdelete! '..expand('<abuf>') | endif
+]])
-- options
+--dap.set_exception_breakpoints("default")
dap.defaults.fallback.focus_terminal = false
dap.defaults.fallback.terminal_win_cmd = '10split new'