aboutsummaryrefslogtreecommitdiffstats
path: root/lua/pi/dap/configs/rust.old
blob: 9ca976f24b716cf6c6e7c44c4a7b04ba18812d0b (plain)
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
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