Compare commits
2 Commits
124f7ac751
...
3afc48617a
Author | SHA1 | Date | |
---|---|---|---|
3afc48617a | |||
47419e74f8 |
@ -24,16 +24,16 @@
|
||||
# dynamic width from 0 to 300
|
||||
# width = (0, 300)
|
||||
# constant width of 300
|
||||
width = 300
|
||||
width = (0, 300)
|
||||
|
||||
# The maximum height of a single notification, excluding the frame.
|
||||
height = 300
|
||||
height = (0, 300)
|
||||
|
||||
# Position the notification in the top right corner
|
||||
origin = top-right
|
||||
|
||||
# Offset from the origin
|
||||
offset = 10x50
|
||||
offset = (50, 10)
|
||||
|
||||
# Scale factor. It is auto-detected if value is 0.
|
||||
scale = 0
|
||||
@ -81,7 +81,7 @@
|
||||
# The transparency of the window. Range: [0; 100].
|
||||
# This option will only work if a compositing window manager is
|
||||
# present (e.g. xcompmgr, compiz, etc.). (X11 only)
|
||||
transparency = 0
|
||||
transparency = 99
|
||||
|
||||
# Draw a line of "separator_height" pixel height between two
|
||||
# notifications.
|
||||
@ -103,7 +103,7 @@
|
||||
frame_width = 2
|
||||
|
||||
# Defines color of the frame around the notification window.
|
||||
frame_color = "#ffffff11"
|
||||
frame_color = "#ff4d00"
|
||||
|
||||
# Size of gap to display between notifications - requires a compositor.
|
||||
# If value is greater than 0, separator_height will be ignored and a border
|
||||
@ -263,7 +263,7 @@
|
||||
# corners.
|
||||
# The radius will be automatically lowered if it exceeds half of the
|
||||
# notification height to avoid clipping text and/or icons.
|
||||
corner_radius = 8
|
||||
corner_radius = 2
|
||||
|
||||
# Define which corners to round when drawing the window. If the corner radius
|
||||
# is set to 0 this option will be ignored.
|
||||
|
@ -1,3 +1,60 @@
|
||||
-- Function to evaluate the variable or expression under the cursor or selected in visual mode
|
||||
local function dap_evaluate_expression()
|
||||
local dap = require("dap")
|
||||
if not dap.session() then
|
||||
print("No active debug session")
|
||||
return
|
||||
end
|
||||
|
||||
-- Determine if we're in visual mode and get the expression
|
||||
local expression
|
||||
local mode = vim.fn.mode()
|
||||
if mode == "v" or mode == "V" or mode == "<C-v>" then
|
||||
-- Visual mode: grab the selected text
|
||||
local start_pos = vim.fn.getpos("v")
|
||||
local end_pos = vim.fn.getpos(".")
|
||||
local start_line, start_col = start_pos[2], start_pos[3]
|
||||
local end_line, end_col = end_pos[2], end_pos[3]
|
||||
|
||||
-- Handle multi-line selections or single-line selections
|
||||
if start_line == end_line then
|
||||
local line = vim.fn.getline(start_line)
|
||||
expression = string.sub(line, start_col, end_col)
|
||||
else
|
||||
local lines = vim.fn.getline(start_line, end_line)
|
||||
lines[1] = string.sub(lines[1], start_col)
|
||||
lines[#lines] = string.sub(lines[#lines], 1, end_col)
|
||||
expression = table.concat(lines, "\n")
|
||||
end
|
||||
|
||||
-- Exit visual mode after grabbing the selection
|
||||
vim.api.nvim_command("normal! <Esc>")
|
||||
else
|
||||
-- Normal mode: grab the word under the cursor
|
||||
expression = vim.fn.expand("<cword>")
|
||||
end
|
||||
|
||||
-- Ask the debugger to evaluate the expression
|
||||
dap.session():request("evaluate", {
|
||||
expression = expression,
|
||||
context = "repl",
|
||||
}, function(err, response)
|
||||
if err then
|
||||
print("Error evaluating expression: " .. err.message)
|
||||
return
|
||||
end
|
||||
if response and response.result then
|
||||
-- Show the result in the command line
|
||||
vim.api.nvim_echo({ { expression .. " = " .. response.result, "Normal" } }, true, {})
|
||||
else
|
||||
print("No result for expression: " .. expression)
|
||||
end
|
||||
end)
|
||||
end
|
||||
|
||||
-- Bind it to a key, e.g., <leader>de
|
||||
vim.keymap.set("n", "<leader>de", dap_evaluate_expression, { desc = "Evaluate expression under cursor" })
|
||||
|
||||
return {
|
||||
"mfussenegger/nvim-dap",
|
||||
recommended = true,
|
||||
@ -42,6 +99,20 @@ return {
|
||||
end
|
||||
for _, lang in ipairs({ "typescript", "javascript", "typescriptreact", "javascriptreact" }) do
|
||||
dap.configurations[lang] = {
|
||||
{
|
||||
type = "pwa-node",
|
||||
request = "launch",
|
||||
name = "Launch NestJS App",
|
||||
program = "${workspaceFolder}/src/main.ts",
|
||||
runtimeExecutable = "node",
|
||||
runtimeArgs = { "-r", "ts-node/register" },
|
||||
envFile = "${workspaceFolder}/.env",
|
||||
trace = true,
|
||||
cwd = "${workspaceFolder}",
|
||||
sourceMaps = true,
|
||||
protocol = "inspector",
|
||||
console = "integratedTerminal",
|
||||
},
|
||||
{
|
||||
type = "pwa-node",
|
||||
request = "launch",
|
||||
@ -88,6 +159,23 @@ return {
|
||||
},
|
||||
}
|
||||
|
||||
dap.adapters.cortex = {
|
||||
type = "executable",
|
||||
command = "arm-none-eabi-gdb",
|
||||
args = { "-x", "${workspaceFolder}/debug.gdb" },
|
||||
}
|
||||
|
||||
dap.configurations.c = {
|
||||
{
|
||||
name = "Debug STM32",
|
||||
type = "cortex",
|
||||
request = "launch",
|
||||
program = "${workspaceFolder}/build/main.elf",
|
||||
cwd = "${workspaceFolder}",
|
||||
stopOnEntry = true,
|
||||
},
|
||||
}
|
||||
|
||||
-- setup dap config by VsCode launch.json file
|
||||
local vscode = require("dap.ext.vscode")
|
||||
local json = require("plenary.json")
|
||||
@ -110,6 +198,12 @@ return {
|
||||
end,
|
||||
desc = "Breakpoint Condition",
|
||||
},
|
||||
{
|
||||
"<leader>de",
|
||||
dap_evaluate_expression,
|
||||
desc = "Evaluate expression under cursor or selection",
|
||||
mode = { "n", "v" },
|
||||
},
|
||||
{
|
||||
"<leader>db",
|
||||
function()
|
||||
|
@ -0,0 +1,39 @@
|
||||
return {
|
||||
"theHamsta/nvim-dap-virtual-text",
|
||||
config = function()
|
||||
require("nvim-dap-virtual-text").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 = false, -- 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)
|
||||
clear_on_continue = false, -- clear virtual text on "continue" (might cause flickering when stepping)
|
||||
--- A callback that determines how a variable is displayed or whether it should be omitted
|
||||
--- @param variable Variable https://microsoft.github.io/debug-adapter-protocol/specification#Types_Variable
|
||||
--- @param buf number
|
||||
--- @param stackframe dap.StackFrame https://microsoft.github.io/debug-adapter-protocol/specification#Types_StackFrame
|
||||
--- @param node userdata tree-sitter node identified as variable definition of reference (see `:h tsnode`)
|
||||
--- @param options nvim_dap_virtual_text_options Current options for nvim-dap-virtual-text
|
||||
--- @return string|nil A text how the virtual text should be displayed or nil, if this variable shouldn't be displayed
|
||||
display_callback = function(variable, buf, stackframe, node, options)
|
||||
-- by default, strip out new line characters
|
||||
if options.virt_text_pos == "inline" then
|
||||
return " = " .. variable.value:gsub("%s+", " ")
|
||||
else
|
||||
return variable.name .. " = " .. variable.value:gsub("%s+", " ")
|
||||
end
|
||||
end,
|
||||
-- position of virtual text, see `:h nvim_buf_set_extmark()`, default tries to inline the virtual text. Use 'eol' to set to end of line
|
||||
virt_text_pos = vim.fn.has("nvim-0.10") == 1 and "inline" or "eol",
|
||||
|
||||
-- experimental features:
|
||||
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()`
|
||||
})
|
||||
end,
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user