diff options
| author | Ariel D'Alessandro <dalessandro.ariel@gmail.com> | 2022-12-17 23:28:32 +0100 |
|---|---|---|
| committer | Ariel D'Alessandro <dalessandro.ariel@gmail.com> | 2022-12-17 23:28:32 +0100 |
| commit | ddf423361d357228661b2cee4a952693f0ac7237 (patch) | |
| tree | 1450ce27a748b315be38adee36ba1131df6bbb5d /lua/alpha/dap.lua | |
| parent | 740aeeefce01d9f60ca1ca095c919691892b6c75 (diff) | |
| download | nvim-conf-ddf423361d357228661b2cee4a952693f0ac7237.tar.gz nvim-conf-ddf423361d357228661b2cee4a952693f0ac7237.zip | |
Update dap
Diffstat (limited to 'lua/alpha/dap.lua')
| -rw-r--r-- | lua/alpha/dap.lua | 100 |
1 files changed, 74 insertions, 26 deletions
diff --git a/lua/alpha/dap.lua b/lua/alpha/dap.lua index 0776ba7..6d0bda0 100644 --- a/lua/alpha/dap.lua +++ b/lua/alpha/dap.lua @@ -1,9 +1,10 @@ local dap, dapui, dap_go = require("dap"), require("dapui"), require("dap-go") -local composer = require("composer") require("nvim-dap-virtual-text").setup({}) -- dap.set_log_level('TRACE') +dap_go.setup() + dapui.setup({ icons = { expanded = "โพ", collapsed = "โธ" }, layouts = { @@ -28,16 +29,12 @@ dapui.setup({ }, }) -dap_go.setup() - vim.fn.sign_define("DapBreakpoint", { text = "๐", texthl = "", linehl = "", numhl = "" }) vim.fn.sign_define("DapStopped", { text = "โถ", texthl = "", linehl = "", numhl = "" }) vim.fn.sign_define("DapBreakpointRejected", { text = "๐ซ", texthl = "", linehl = "", numhl = "" }) vim.fn.sign_define("DapBreakpointCondition", { text = "โ", texthl = "", linehl = "", numhl = "" }) vim.fn.sign_define("DapLogPoint", { text = "๐ฌ", texthl = "", linehl = "", numhl = "" }) --- vim.cmd("au FileType dap-repl lua require('dap.ext.autocompl').attach()") - dap.adapters.php = { type = "executable", command = "php-debug-adapter", @@ -47,32 +44,91 @@ dap.configurations.php = { { type = "php", request = "launch", - name = "Listen for Xdebug", + name = "Laravel", port = 9003, - pathMappings = function() - if composer.query({"require-dev", "laravel/sali"}) == nil then - return { ["/app"] = "${workspaceFolder}" } - end - return { ["/var/www/html"] = "${workspaceFolder}" } - end, + pathMappings = { + ["/var/www/html"] = "${workspaceFolder}", + }, + }, + { + type = "php", + request = "launch", + name = "Symfony", + port = 9003, + pathMappings = { + ["/app"] = "${workspaceFolder}", + }, }, } +require("dap-vscode-js").setup({ + -- node_path = "node", -- Path of node executable. Defaults to $NODE_PATH, and then "node" + -- debugger_path = "(runtimedir)/site/pack/packer/opt/vscode-js-debug", -- Path to vscode-js-debug installation. + debugger_cmd = { "js-debug-adapter" }, -- Command to use to launch the debug server. Takes precedence over `node_path` and `debugger_path`. + adapters = { "pwa-node", "pwa-chrome", "pwa-msedge", "node-terminal", "pwa-extensionHost" }, -- which adapters to register in nvim-dap + -- log_file_path = "(stdpath cache)/dap_vscode_js.log" -- Path for file logging + -- log_file_level = false -- Logging level for output to file. Set to false to disable file logging. + -- log_console_level = vim.log.levels.ERROR -- Logging level for output to console. Set to false to disable console output. +}) + +for _, language in ipairs({ "typescript", "javascript" }) do + require("dap").configurations[language] = { + { + type = "pwa-node", + request = "launch", + name = "Launch file", + program = "${file}", + cwd = "${workspaceFolder}", + }, + { + type = "pwa-node", + request = "attach", + name = "Attach", + processId = require("dap.utils").pick_process, + cwd = "${workspaceFolder}", + }, + } +end + +for _, language in ipairs({ "typescriptreact", "javascriptreact" }) do + require("dap").configurations[language] = { + { + type = "pwa-chrome", + name = "Attach - Remote Debugging", + request = "attach", + program = "${file}", + cwd = vim.fn.getcwd(), + sourceMaps = true, + protocol = "inspector", + port = 9222, + webRoot = "${workspaceFolder}", + }, + { + type = "pwa-chrome", + name = "Launch Chrome", + request = "launch", + url = "http://localhost:3000", + }, + } +end + -- Events Listeners --- dap.listeners.after.event_initialized["dapui_config"] = function() --- dapui.open({}) --- end +dap.listeners.after.event_initialized["dapui_config"] = function() + dapui.open({}) +end local hydra = require("hydra") local hint = [[ Nvim DAP _d_: Start/Continue _j_: StepOver _k_: StepOut _l_: StepInto ^ _bp_: Toogle Breakpoint _bc_: Conditional Breakpoint ^ - _c_: Run To Cursor _tt_: Go Debug Test - _h_: Show information of the variable under the cursor _?_ log point - _s_: Start _x_: Stop Debbuging + _?_: log point ^ + _c_: Run To Cursor ^ + _h_: Show information of the variable under the cursor ^ + _x_: Stop Debbuging ^ ^^ _<Esc>_ ]] + hydra({ name = "dap", hint = hint, @@ -88,20 +144,12 @@ hydra({ body = "<leader>d", heads = { { "d", dap.continue }, - { - "s", - function() - dap.continue() - dapui.open({}) - end, - }, { "bp", dap.toggle_breakpoint }, { "l", dap.step_into }, { "j", dap.step_over }, { "k", dap.step_out }, { "h", dapui.eval }, { "c", dap.run_to_cursor }, - { "tt", dap_go.debug_test }, { "bc", function() |