summary refs log tree commit diff
path: root/.vim/lua/internal/dap.lua
diff options
context:
space:
mode:
authorRobert Günzler <r@gnzler.io>2024-11-25 13:30:37 +0100
committerRobert Günzler <r@gnzler.io>2024-11-25 13:58:25 +0100
commit23de12baba9fbfc4ca24581b37c374aa5345cc25 (patch)
treee4b3c421bad572eb85a1089eaad44dc3059ab6e6 /.vim/lua/internal/dap.lua
parent18e3848110da0a59843058927ea04b496f5db2a5 (diff)
update nvim config
Signed-off-by: Robert Günzler <r@gnzler.io>
Diffstat (limited to '')
-rw-r--r--.vim/lua/internal/dap.lua173
1 files changed, 0 insertions, 173 deletions
diff --git a/.vim/lua/internal/dap.lua b/.vim/lua/internal/dap.lua
deleted file mode 100644
index 4b1d776..0000000
--- a/.vim/lua/internal/dap.lua
+++ /dev/null
@@ -1,173 +0,0 @@
--- vim: fdm=marker
-
-local dap = require('dap')
-dap.defaults.fallback.terminal_win_cmd = 'belowright 10new'
-dap.defaults.fallback.focus_terminal = false
-
--- open repl when session starts
-dap.listeners.after['event_initialized']['me'] = function()
-  -- dap.repl.toggle()
-end
-
--- try loading dap-launch.json
--- require('dap.ext.vscode').load_launchjs(vim.fn.getcwd() .. '/dap-launch.json')
-
--- signs
-vim.fn.sign_define({
-  { name = 'DapBreakpoint', text = '🞱', texthl = 'DapBreakpoint', linehl = 'DapBreakpointLn' },
-})
-vim.fn.sign_define({
-  { name = 'DapStopped', text = '→', texthl = 'DapStopped', linehl = 'DapStoppedLn' },
-})
-
--- keymaps
-vim.keymap.set('n', '<leader>dd', dap.toggle_breakpoint, { desc = 'toggle breakpoint' }) -- convenience
-vim.keymap.set('n', '<leader>db', dap.toggle_breakpoint, { desc = 'toggle breakpoint' })
-vim.keymap.set('n', '<leader>dc', dap.continue, { desc = 'continue' })
-vim.keymap.set('n', '<leader>ds', dap.step_over, { desc = 'step over' })
-vim.keymap.set('n', '<leader>di', dap.step_into, { desc = 'step into' })
-vim.keymap.set('n', '<leader>do', dap.step_out, { desc = 'step out' })
-vim.keymap.set('n', '<leader>dR', dap.repl.toggle, { desc = 'toggle REPL' })
-vim.keymap.set('n', '<leader>dL', dap.run_last, { desc = 'run last' })
-vim.keymap.set('n', '<leader>dq', dap.terminate, { desc = 'terminate' })
-
-local widgets = require('dap.ui.widgets')
-vim.keymap.set('n', '<leader>dh', widgets.hover, { desc = 'hover' })
-vim.keymap.set(
-  'n',
-  '<leader>dB',
-  require('telescope').extensions.dap.list_breakpoints,
-  { desc = 'list breakpoints' }
-)
-
--- Common
-local bin_from_var_or_pick = function()
-  local ok, retval = pcall(vim.api.nvim_get_var, 'dap_bin') -- global let g:dap_bin
-  if ok then
-    local workspace_folders = vim.lsp.buf.list_workspace_folders()
-    if #workspace_folders >= 1 then
-      retval = retval:gsub(':workspace', workspace_folders[1])
-    end
-    return retval
-  end
-  -- NOTE: try to resolve binaries from build system
-  local bin = nil
-  vim.ui.input({ prompt = 'DAP: binary to launch: ' }, function(choice)
-    bin = choice
-  end)
-  if not bin == nil then
-    return bin
-  end
-  return false
-end
-
--- Go {{{
-dap.adapters.go_dlv_local = function(callback, config) -- {{{
-  local stdout = vim.loop.new_pipe()
-  local handle
-  local pid_or_err
-  local port = 38697
-  local opts = {
-    stdio = { nil, stdout },
-    args = { 'dap', '-l', '127.0.0.1:' .. port },
-    detached = true,
-  }
-  handle, pid_or_err = vim.loop.spawn('dlv', opts, function(exit)
-    stdout:close()
-    handle:close()
-    if exit ~= 0 then
-      vim.notify('dlv exited with exit code ' .. exit)
-    end
-  end)
-  assert(handle, 'Error running dlv: ' .. tostring(pid_or_err))
-  stdout:read_start(function(err, chunk)
-    assert(not err, err)
-    if chunk then
-      vim.schedule(function()
-        require('dap.repl').append(chunk)
-      end)
-    end
-  end)
-  vim.defer_fn(function()
-    callback({ type = 'server', host = '127.0.0.1', port = port })
-  end, 100)
-end -- }}}
-
-dap.adapters.go_dlv_remote = {
-  type = 'server',
-  host = '127.0.0.1',
-  port = 38697,
-}
-
-dap.configurations.go = {
-  {
-    name = 'Debug (local)',
-    type = 'go_dlv_local',
-    request = 'launch',
-    program = '${file}',
-  },
-  {
-    name = 'Debug (remote)',
-    type = 'go_dlv_remote',
-    request = 'launch',
-    mode = 'exec',
-    program = bin_from_var_or_pick,
-  },
-}
--- end of Go }}}
-
--- C/C++/Rust {{{
-dap.adapters.lldb = {
-  type = 'executable',
-  command = '/usr/bin/lldb-vscode',
-  name = 'lldb',
-}
-
-dap.configurations.c = {
-  {
-    name = 'Launch',
-    type = 'lldb',
-    request = 'launch',
-    program = bin_from_var_or_pick,
-    args = {},
-    cwd = '${workspaceFolder}',
-    stopOnEntry = false,
-  },
-  {
-    name = 'Attach',
-    type = 'lldb',
-    request = 'attach',
-    pid = require('dap.utils').pick_process,
-    args = {},
-  },
-}
-dap.configurations.cpp = dap.configurations.c
-
--- enable rust types
-dap.configurations.rust = vim.tbl_extend('force', dap.configurations.c, {
-  initCommands = function()
-    local rustc_sysroot = vim.fn.trim(vim.fn.system('rustc --print sysroot'))
-
-    local script_import = 'command script import "'
-        .. rustc_sysroot
-        .. '/lib/rustlib/etc/lldb_lookup.py"'
-    local commands_file = rustc_sysroot .. '/lib/rustlib/etc/lldb_commands'
-
-    local commands = {}
-    local file = io.open(commands_file, 'r')
-    if file then
-      for line in file:lines() do
-        table.insert(commands, line)
-      end
-      file:close()
-    end
-    table.insert(commands, 1, script_import)
-
-    return commands
-  end,
-})
--- end of C/C++/Rust }}}
-
-local dapui = require('dapui')
-dapui.setup {}
-vim.keymap.set('n', '<leader>du', dapui.toggle, { desc = 'toggle ui' })