nvim: add basic JS debug adapter
This commit is contained in:
parent
404837e2a0
commit
4b8a51b854
|
@ -7,28 +7,30 @@
|
|||
"cmp-path": { "branch": "main", "commit": "91ff86cd9c29299a64f968ebb45846c485725f23" },
|
||||
"cmp_luasnip": { "branch": "master", "commit": "05a9ab28b53f71d1aece421ef32fee2cb857a843" },
|
||||
"diffview.nvim": { "branch": "main", "commit": "3dc498c9777fe79156f3d32dddd483b8b3dbd95f" },
|
||||
"gitsigns.nvim": { "branch": "main", "commit": "0a2a93f687ec051292943a4d139366332ac93688" },
|
||||
"haskell-tools.nvim": { "branch": "master", "commit": "2faa2c879c82652f1df3974c185901cf93c6367c" },
|
||||
"gitsigns.nvim": { "branch": "main", "commit": "2c2463dbd82eddd7dbab881c3a62cfbfbe3c67ae" },
|
||||
"haskell-tools.nvim": { "branch": "master", "commit": "1b739495b2b3ed82d18d7de367cc2754f33d2c15" },
|
||||
"kanagawa.nvim": { "branch": "master", "commit": "c19b9023842697ec92caf72cd3599f7dd7be4456" },
|
||||
"lazy.nvim": { "branch": "main", "commit": "aedcd79811d491b60d0a6577a9c1701063c2a609" },
|
||||
"lualine.nvim": { "branch": "master", "commit": "7d131a8d3ba5016229e8a1d08bf8782acea98852" },
|
||||
"mason-lspconfig.nvim": { "branch": "main", "commit": "b9084b1f42f790d6230dc66dbcb6bcc35b148552" },
|
||||
"mason-nvim-dap.nvim": { "branch": "main", "commit": "3614a39aae98ccd34124b072939d6283853b3dd2" },
|
||||
"mason.nvim": { "branch": "main", "commit": "9c9416817c9f4e6f333c749327a1ed5355cfab61" },
|
||||
"mason.nvim": { "branch": "main", "commit": "dcd0ea30ccfc7d47e879878d1270d6847a519181" },
|
||||
"neo-tree.nvim": { "branch": "v3.x", "commit": "2f2d08894bbc679d4d181604c16bb7079f646384" },
|
||||
"neodev.nvim": { "branch": "main", "commit": "3408a4daeca5ff8f41cb2c668b6d8fcc665f793a" },
|
||||
"neodev.nvim": { "branch": "main", "commit": "64b2a51b02c6f2ae177c745e4d8bc801a339fe09" },
|
||||
"neogit": { "branch": "master", "commit": "ce0c369ccdba3f644a3b28f4c053421f435352c9" },
|
||||
"nui.nvim": { "branch": "main", "commit": "35da9ca1de0fc4dda96c2e214d93d363c145f418" },
|
||||
"nvim-cmp": { "branch": "main", "commit": "538e37ba87284942c1d76ed38dd497e54e65b891" },
|
||||
"nvim-dap": { "branch": "master", "commit": "9adbfdca13afbe646d09a8d7a86d5d031fb9c5a5" },
|
||||
"nvim-dap-ui": { "branch": "master", "commit": "d845ebd798ad1cf30aa4abd4c4eff795cdcfdd4f" },
|
||||
"nvim-dap-vscode-js": { "branch": "main", "commit": "03bd29672d7fab5e515fc8469b7d07cc5994bbf6" },
|
||||
"nvim-lspconfig": { "branch": "master", "commit": "8917d2c830e04bf944a699b8c41f097621283828" },
|
||||
"nvim-notify": { "branch": "master", "commit": "80b67b265530632505193553d05127ae7fe09ddd" },
|
||||
"nvim-treesitter": { "branch": "master", "commit": "ce4adf11cfe36fc5b0e5bcdce0c7c6e8fbc9798a" },
|
||||
"nvim-treesitter": { "branch": "master", "commit": "458ce4d16c1771fc601ec10a87820acae9981f6d" },
|
||||
"nvim-web-devicons": { "branch": "master", "commit": "b427ac5f9dff494f839e81441fb3f04a58cbcfbc" },
|
||||
"plenary.nvim": { "branch": "master", "commit": "663246936325062427597964d81d30eaa42ab1e4" },
|
||||
"rustaceanvim": { "branch": "master", "commit": "bc8c4b8f7606d5b7c067cd8369e25c1a7ff77bd0" },
|
||||
"telescope-fzf-native.nvim": { "branch": "main", "commit": "6c921ca12321edaa773e324ef64ea301a1d0da62" },
|
||||
"telescope.nvim": { "branch": "0.1.x", "commit": "d90956833d7c27e73c621a61f20b29fdb7122709" },
|
||||
"vscode-js-debug": { "branch": "main", "commit": "61adc31bbc0fabdc620ba5202d71d92189c55b81" },
|
||||
"which-key.nvim": { "branch": "main", "commit": "4433e5ec9a507e5097571ed55c02ea9658fb268a" }
|
||||
}
|
|
@ -1,6 +1,7 @@
|
|||
local is, when = require 'config.compose' ()
|
||||
local map = require 'config.helpers.keymap'
|
||||
local n = map 'n'
|
||||
local nv = map { 'n', 'v' }
|
||||
|
||||
|
||||
---@type LazySpec
|
||||
|
@ -271,33 +272,29 @@ return {
|
|||
{
|
||||
'mfussenegger/nvim-dap',
|
||||
enabled = is { 'standalone', 'linux' },
|
||||
dependencies = {
|
||||
'rcarriga/nvim-dap-ui',
|
||||
},
|
||||
config = function()
|
||||
local dap = require 'dap'
|
||||
local ui = require 'dapui'
|
||||
|
||||
local function cond_breakpoint()
|
||||
local cond = vim.fn.input('Breakpoint condition: ')
|
||||
dap.set_breakpoint(cond)
|
||||
end
|
||||
n '<F5>' (dap.continue) 'Debugger: continue'
|
||||
n '<F10>' (dap.step_over) 'Debugger: step over'
|
||||
n '<F11>' (dap.step_into) 'Debugger: step into'
|
||||
n '<F12>' (dap.step_out) 'Debugger: step out'
|
||||
n '<leader>db' (dap.toggle_breakpoint) 'Debugger: toggle breakpoint'
|
||||
|
||||
n '<F5>' (dap.continue) 'Debugger: continue'
|
||||
n '<F10>' (dap.step_over) 'Debugger: step over'
|
||||
n '<F11>' (dap.step_into) 'Debugger: step into'
|
||||
n '<F12>' (dap.step_out) 'Debugger: step out'
|
||||
n '<leader>b' (dap.toggle_breakpoint) 'Debugger: toggle berakpoint'
|
||||
n '<leader>B' (cond_breakpoint) 'Debugger: toggle breakpoint (cond)'
|
||||
n '<leader>du' (ui.toggle) 'Debugger: toggle UI'
|
||||
nv '<leader>de' (ui.eval) 'Debugger: eval'
|
||||
|
||||
ui.setup()
|
||||
dap.listeners.after.event_initialized["dapui_config"] = ui.open
|
||||
dap.listeners.after.event_terminated["dapui_config"] = ui.close
|
||||
dap.listeners.before.event_exited["dapui_config"] = ui.close
|
||||
end,
|
||||
},
|
||||
|
||||
-- Debugger UI
|
||||
{
|
||||
'rcarriga/nvim-dap-ui',
|
||||
enabled = is { 'standalone', 'linux' },
|
||||
dependencies = {
|
||||
'mfussenegger/nvim-dap',
|
||||
},
|
||||
config = require 'config.plugins.nvim-dap-ui'
|
||||
},
|
||||
|
||||
-- Mason
|
||||
{
|
||||
'williamboman/mason.nvim',
|
||||
|
@ -368,6 +365,7 @@ return {
|
|||
automatic_installation = true,
|
||||
ensure_installed = {
|
||||
'codelldb',
|
||||
--'js-debug-adapter',
|
||||
},
|
||||
}
|
||||
end,
|
||||
|
@ -418,4 +416,63 @@ return {
|
|||
init = require 'config.plugins.haskell-tools'
|
||||
},
|
||||
|
||||
-- JS debugger
|
||||
{
|
||||
'mxsdev/nvim-dap-vscode-js',
|
||||
dependencies = {
|
||||
'microsoft/vscode-js-debug',
|
||||
version = '1.x',
|
||||
build = 'npm i && npm run compile vsDebugServerBundle && mv dist out',
|
||||
},
|
||||
config = function()
|
||||
local dap = require 'dap'
|
||||
--local utils = require 'dap.utils'
|
||||
local dap_js = require 'dap-vscode-js'
|
||||
--local mason = require 'mason-registry'
|
||||
|
||||
---@diagnostic disable-next-line: missing-fields
|
||||
dap_js.setup {
|
||||
-- debugger_path = mason.get_package('js-debug-adapter'):get_install_path(),
|
||||
debugger_path = vim.fn.stdpath 'data' .. '/lazy/vscode-js-debug',
|
||||
adapters = { 'pwa-node', 'pwa-chrome', 'pwa-msedge', 'node-terminal', 'pwa-extensionHost' },
|
||||
}
|
||||
|
||||
local langs = { 'javascript', 'typescript', 'svelte', 'astro' }
|
||||
for _, lang in ipairs(langs) do
|
||||
dap.configurations[lang] = {
|
||||
-- attach to a node process that has been started with
|
||||
-- `--inspect` for longrunning tasks or `--inspect-brk` for short tasks
|
||||
-- npm script -> `node --inspect-brk ./node_modules/.bin/vite dev`
|
||||
{
|
||||
-- use nvim-dap-vscode-js's pwa-node debug adapter
|
||||
type = 'pwa-node',
|
||||
-- attach to an already running node process with --inspect flag
|
||||
-- default port: 9222
|
||||
request = 'attach',
|
||||
-- allows us to pick the process using a picker
|
||||
processId = require('dap.utils').pick_process,
|
||||
-- name of the debug action you have to select for this config
|
||||
name = 'Attach debugger to existing `node --inspect` process',
|
||||
-- for compiled languages like TypeScript or Svelte.js
|
||||
sourceMaps = true,
|
||||
-- resolve source maps in nested locations while ignoring node_modules
|
||||
resolveSourceMapLocations = {
|
||||
'${workspaceFolder}/**',
|
||||
'!**/node_modules/**',
|
||||
},
|
||||
-- path to src in vite based projects (and most other projects as well)
|
||||
cwd = '${workspaceFolder}',
|
||||
-- we don't want to debug code inside node_modules, so skip it!
|
||||
skipFiles = {
|
||||
'${workspaceFolder}/node_modules/**/*.js',
|
||||
'${workspaceFolder}/packages/**/node_modules/**/*.js',
|
||||
'${workspaceFolder}/packages/**/**/node_modules/**/*.js',
|
||||
'<node_internals>/**',
|
||||
'node_modules/**',
|
||||
},
|
||||
},
|
||||
}
|
||||
end
|
||||
end,
|
||||
},
|
||||
}
|
||||
|
|
|
@ -1,87 +0,0 @@
|
|||
return function()
|
||||
local dap = require "dap"
|
||||
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") == 1,
|
||||
-- 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.
|
||||
"breakpoints",
|
||||
"stacks",
|
||||
"watches",
|
||||
{ id = "scopes", size = 0.25 },
|
||||
},
|
||||
size = 40, -- 40 columns
|
||||
position = "left",
|
||||
},
|
||||
{
|
||||
elements = {
|
||||
"repl",
|
||||
"console",
|
||||
},
|
||||
size = 0.25, -- 25% 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.
|
||||
},
|
||||
})
|
||||
|
||||
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
|
||||
end
|
Loading…
Reference in a new issue