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/alpha/dap/configs/rust.lua | |
| parent | 61499082db8f34ca38fc9eb916f9cc87d82e7655 (diff) | |
| download | nvim-conf-8fc48402953a9d91e5c05662c7fa6dfae8605fc9.tar.gz nvim-conf-8fc48402953a9d91e5c05662c7fa6dfae8605fc9.zip | |
feat: improve dap
Diffstat (limited to 'lua/alpha/dap/configs/rust.lua')
| -rw-r--r-- | lua/alpha/dap/configs/rust.lua | 57 |
1 files changed, 57 insertions, 0 deletions
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 |