diff options
| author | adalessa <dalessandro.ariel@gmail.com> | 2023-03-04 16:14:13 +0100 |
|---|---|---|
| committer | adalessa <dalessandro.ariel@gmail.com> | 2023-03-04 16:14:13 +0100 |
| commit | 8fc48402953a9d91e5c05662c7fa6dfae8605fc9 (patch) | |
| tree | 76e266425d780f7b93e7e40bbf1cf9485c3700cc /lua | |
| parent | 61499082db8f34ca38fc9eb916f9cc87d82e7655 (diff) | |
| download | nvim-conf-8fc48402953a9d91e5c05662c7fa6dfae8605fc9.tar.gz nvim-conf-8fc48402953a9d91e5c05662c7fa6dfae8605fc9.zip | |
feat: improve dap
Diffstat (limited to 'lua')
| -rw-r--r-- | lua/alpha/dap/configs/golang.lua | 1 | ||||
| -rw-r--r-- | lua/alpha/dap/configs/javascript.lua | 45 | ||||
| -rw-r--r-- | lua/alpha/dap/configs/php.lua | 27 | ||||
| -rw-r--r-- | lua/alpha/dap/configs/rust.lua | 57 | ||||
| -rw-r--r-- | lua/alpha/dap/init.lua (renamed from lua/alpha/dap.lua) | 95 | ||||
| -rw-r--r-- | lua/alpha/lsp/tools.lua | 2 |
6 files changed, 145 insertions, 82 deletions
diff --git a/lua/alpha/dap/configs/golang.lua b/lua/alpha/dap/configs/golang.lua new file mode 100644 index 0000000..1ec449a --- /dev/null +++ b/lua/alpha/dap/configs/golang.lua @@ -0,0 +1 @@ +require("dap-go").setup() diff --git a/lua/alpha/dap/configs/javascript.lua b/lua/alpha/dap/configs/javascript.lua new file mode 100644 index 0000000..b910f30 --- /dev/null +++ b/lua/alpha/dap/configs/javascript.lua @@ -0,0 +1,45 @@ +require("dap-vscode-js").setup { + debugger_cmd = { "js-debug-adapter" }, + adapters = { "pwa-node", "pwa-chrome", "node-terminal" }, +} + +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 diff --git a/lua/alpha/dap/configs/php.lua b/lua/alpha/dap/configs/php.lua new file mode 100644 index 0000000..968bb9d --- /dev/null +++ b/lua/alpha/dap/configs/php.lua @@ -0,0 +1,27 @@ +local dap = require("dap") + +dap.adapters.php = { + type = "executable", + command = "php-debug-adapter", +} + +dap.configurations.php = { + { + type = "php", + request = "launch", + name = "Laravel", + port = 9003, + pathMappings = { + ["/var/www/html"] = "${workspaceFolder}", + }, + }, + { + type = "php", + request = "launch", + name = "Symfony", + port = 9003, + pathMappings = { + ["/app"] = "${workspaceFolder}", + }, + }, +} diff --git a/lua/alpha/dap/configs/rust.lua b/lua/alpha/dap/configs/rust.lua new file mode 100644 index 0000000..9ca976f --- /dev/null +++ b/lua/alpha/dap/configs/rust.lua @@ -0,0 +1,57 @@ +local dap = require("dap") + +local rust_adapter = nil +local rust_adapters = { "lldb-vscode", "codelldb" } +for _, adapter in pairs(rust_adapters) do + if vim.fn.executable(adapter) then + rust_adapter = adapter + end +end + +if rust_adapter ~= nil then + dap.adapters.lldb = { + type = "executable", + command = rust_adapter, + name = "lldb", + } + + dap.configurations.rust = { + { + name = "launch", + type = "lldb", + request = "launch", + program = function() + local dir = vim.fn.getcwd() + return dir .. "/target/debug/" .. vim.fs.basename(dir) + end, + cwd = "${workspaceFolder}", + stopOnEntry = false, + args = function() + local resp = vim.fn.input "Arguments: " + if resp == "" then + return {} + end + + return vim.fn.split(resp, " ") + end, + }, + { + name = "custom", + type = "lldb", + request = "launch", + program = function() + return vim.fn.input("Path to executable: ", vim.fn.getcwd() .. "/", "file") + end, + cwd = "${workspaceFolder}", + stopOnEntry = false, + args = function() + local resp = vim.fn.input "Arguments: " + if resp == "" then + return {} + end + + return vim.fn.split(resp, " ") + end, + }, + } +end diff --git a/lua/alpha/dap.lua b/lua/alpha/dap/init.lua index a89d72e..1d69cf9 100644 --- a/lua/alpha/dap.lua +++ b/lua/alpha/dap/init.lua @@ -1,10 +1,20 @@ -local dap, dapui, dap_go = require "dap", require "dapui", require "dap-go" +local dap, dapui, hydra = require "dap", require "dapui", require "hydra" +-- Setup Virtual Text require("nvim-dap-virtual-text").setup {} --- dap.set_log_level('TRACE') -dap_go.setup() +for _, ft_path in ipairs(vim.api.nvim_get_runtime_file("lua/alpha/dap/configs/*.lua", true)) do + loadfile(ft_path)() +end +-- Signs +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 = "" }) + +-- UI structure dapui.setup { icons = { expanded = "โพ", collapsed = "โธ" }, layouts = { @@ -29,90 +39,11 @@ dapui.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 = "" }) - -dap.adapters.php = { - type = "executable", - command = "php-debug-adapter", -} - -dap.configurations.php = { - { - type = "php", - request = "launch", - name = "Laravel", - port = 9003, - pathMappings = { - ["/var/www/html"] = "${workspaceFolder}", - }, - }, - { - type = "php", - request = "launch", - name = "Symfony", - port = 9003, - pathMappings = { - ["/app"] = "${workspaceFolder}", - }, - }, -} - -require("dap-vscode-js").setup { - debugger_cmd = { "js-debug-adapter" }, - adapters = { "pwa-node", "pwa-chrome", "node-terminal" }, -} - -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 -local hydra = require "hydra" local hint = [[ Nvim DAP _d_: Start/Continue _j_: StepOver _k_: StepOut _l_: StepInto ^ diff --git a/lua/alpha/lsp/tools.lua b/lua/alpha/lsp/tools.lua index 68607d5..4eb40b3 100644 --- a/lua/alpha/lsp/tools.lua +++ b/lua/alpha/lsp/tools.lua @@ -1,4 +1,6 @@ return { "go-debug-adapter", "php-debug-adapter", + "js-debug-adapter", + "codelldb", } |