-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdappy.lua
204 lines (186 loc) · 6.54 KB
/
dappy.lua
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
-- setup adapters
require('dap-vscode-js').setup({
adapters = { 'pwa-node', 'pwa-chrome', 'pwa-msedge', 'node-terminal', 'pwa-extensionHost' },
})
require('dap-python').setup('/home/amrit/.virtualenvs/debugpy/bin/python')
local dap = require('dap')
-- -- custom adapter for running tasks before starting debug
-- local custom_adapter = 'pwa-node-custom'
-- dap.adapters[custom_adapter] = function(cb, config)
-- if config.preLaunchTask then
-- local async = require('plenary.async')
-- local notify = require('notify').async
--
-- async.run(function()
-- ---@diagnostic disable-next-line: missing-parameter
-- notify('Running [' .. config.preLaunchTask .. ']').events.close()
-- end, function()
-- vim.fn.system(config.preLaunchTask)
-- config.type = 'pwa-node'
-- dap.run(config)
-- end)
-- end
-- end
-- language config
for _, language in ipairs({ 'typescript', 'javascript' }) do
dap.configurations[language] = {
{
name = 'Launch',
type = 'pwa-node',
request = 'launch',
runtimeArgs = { "--nolazy", "-r", "ts-node/register/transpile-only" },
program = '${file}',
rootPath = '${workspaceFolder}',
cwd = '${workspaceFolder}',
sourceMaps = true,
skipFiles = { '<node_internals>/**' },
protocol = 'inspector',
console = 'integratedTerminal',
env = {
NODE_ENV = 'development'
}
},
{
type = "pwa-node",
request = "launch",
name = "simple",
-- trace = true, -- include debugger info
runtimeExecutable = "yarn",
runtimeArgs = {
"start:web"
},
rootPath = "${workspaceFolder}",
cwd = "${workspaceFolder}",
console = "integratedTerminal",
internalConsoleOptions = "neverOpen",
env = {
NODE_ENV = 'development'
}
},
{
type = "pwa-node",
request = "launch",
name = "Debug Mocha Tests",
-- trace = true, -- include debugger info
runtimeExecutable = "npm",
runtimeArgs = {
"run", "test"
},
rootPath = "${workspaceFolder}",
cwd = "${workspaceFolder}",
console = "integratedTerminal",
internalConsoleOptions = "neverOpen",
env = {
NODE_ENV = 'development'
}
}
}
end
local dapui = require('dapui')
dapui.setup({
icons = { expanded = "▾", collapsed = "▸", current_frame = "▸" },
mappings = {
-- Use a table to apply multiple mappings
expand = { "<CR>", "<2-LeftMouse>" },
open = "o",
remove = "d",
edit = "e",
repl = "r",
toggle = "t",
},
-- Expand lines larger than the window
-- Requires >= 0.7
expand_lines = vim.fn.has("nvim-0.7"),
-- Layouts define sections of the screen to place windows.
-- The position can be "left", "right", "top" or "bottom".
-- The size specifies the height/width depending on position. It can be an Int
-- or a Float. Integer specifies height/width directly (i.e. 20 lines/columns) while
-- Float value specifies percentage (i.e. 0.3 - 30% of available lines/columns)
-- Elements are the elements shown in the layout (in order).
-- Layouts are opened in order so that earlier layouts take priority in window sizing.
layouts = {
{
elements = {
-- Elements can be strings or table with id and size keys.
"console",
"repl"
},
size = 30, -- 30 columns
position = "right",
},
{
elements = {
"watches",
},
size = 0.20, -- 20% of total lines
position = "bottom",
},
},
controls = {
-- Requires Neovim nightly (or 0.8 when released)
enabled = true,
-- Display controls in this element
element = "repl",
icons = {
pause = "",
play = "",
step_into = "",
step_over = "",
step_out = "",
step_back = "",
run_last = "↻",
terminate = "□",
},
},
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>" },
},
},
windows = { indent = 1 },
render = {
max_type_length = nil, -- Can be integer or nil.
max_value_lines = 100, -- Can be integer or nil.
}
})
vim.fn.sign_define("DapBreakpoint", { text = "⬤", texthl = "DiagnosticSignError", linehl = "", numhl = "" })
vim.fn.sign_define('DapStopped', { text = '⏭', texthl = 'DapStopped', linehl = 'DapStopped', numhl = 'DapStopped' })
require("nvim-dap-virtual-text").setup({
-- comment = true,
-- virt_lines = true,
virt_text_pos = 'eol',
display_callback = function(variable, buf, stackframe, node, options)
local text = ""
if options.virt_text_pos == 'inline' then
text = ' = ' .. variable.value
else
text = variable.name .. ' = ' .. variable.value
end
-- Truncate the text to 100 characters if it exceeds that length
if #text > 50 then
text = text:sub(1, 50) .. ".."
end
return text
end,
})
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
vim.keymap.set('n', '<F10>', require 'dapui'.toggle)
vim.keymap.set('n', '<F9>', require('dapui').eval)
vim.keymap.set('n', '<F5>', require 'dap'.continue)
vim.keymap.set('n', '<F6>', require 'dap'.step_over)
vim.keymap.set('n', '<F4>', require 'dap'.step_into)
vim.keymap.set('n', '<F8>', require 'dap'.step_out)
vim.keymap.set('n', '<F7>', require 'dap'.toggle_breakpoint)
vim.keymap.set('n', '<F1>', require 'dap'.clear_breakpoints)
vim.keymap.set('n', '<leader>?', require('telescope.builtin').oldfiles, { desc = '[?] Find recently opened files' })