This commit is contained in:
Jaroslaw Konik 2026-02-18 14:01:42 +01:00
parent ed98ecdac5
commit 24e7e25685

131
init.lua
View file

@ -272,11 +272,6 @@ require("lazy").setup({
"rcarriga/nvim-dap-ui", "rcarriga/nvim-dap-ui",
dependencies = { "mfussenegger/nvim-dap", "nvim-neotest/nvim-nio" } dependencies = { "mfussenegger/nvim-dap", "nvim-neotest/nvim-nio" }
}, },
{
'mrcjkb/rustaceanvim',
version = '^4',
lazy = false,
},
{ {
"folke/trouble.nvim", "folke/trouble.nvim",
dependencies = { "nvim-tree/nvim-web-devicons" }, dependencies = { "nvim-tree/nvim-web-devicons" },
@ -431,6 +426,7 @@ vim.lsp.enable('ts_ls')
vim.lsp.enable('gopls') vim.lsp.enable('gopls')
vim.lsp.enable('basedpyright') vim.lsp.enable('basedpyright')
vim.lsp.enable('gdscript') vim.lsp.enable('gdscript')
vim.lsp.enable('rust_analyzer')
vim.api.nvim_create_autocmd('BufWritePre', { vim.api.nvim_create_autocmd('BufWritePre', {
pattern = { "*.zig" }, pattern = { "*.zig" },
@ -463,17 +459,128 @@ vim.api.nvim_create_autocmd('BufWritePre', {
-- Debugging -- Debugging
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
local dap = require('dap') local dap = require('dap')
dap.adapters.lldb = { dap.adapters.gdb = {
type = 'executable', type = "executable",
command = '/usr/bin/lldb-dap', command = "gdb",
name = 'lldb' args = { "--interpreter=dap", "--eval-command", "set print pretty on" }
}
dap.configurations.c = {
{
name = "Launch",
type = "gdb",
request = "launch",
program = function()
return vim.fn.input('Path to executable: ', vim.fn.getcwd() .. '/', 'file')
end,
args = {}, -- provide arguments if needed
cwd = "${workspaceFolder}",
stopAtBeginningOfMainSubprogram = false,
},
{
name = "Select and attach to process",
type = "gdb",
request = "attach",
program = function()
return vim.fn.input('Path to executable: ', vim.fn.getcwd() .. '/', 'file')
end,
pid = function()
local name = vim.fn.input('Executable name (filter): ')
return require("dap.utils").pick_process({ filter = name })
end,
cwd = '${workspaceFolder}'
},
{
name = 'Attach to gdbserver :1234',
type = 'gdb',
request = 'attach',
target = 'localhost:1234',
program = function()
return vim.fn.input('Path to executable: ', vim.fn.getcwd() .. '/', 'file')
end,
cwd = '${workspaceFolder}'
}
}
dap.configurations.cpp = dap.configurations.c
dap.adapters["rust-gdb"] = {
type = "executable",
command = "rust-gdb",
args = { "--interpreter=dap", "--eval-command", "set print pretty on" }
}
function cargo_test_binary()
local result = vim.system(
{ "cargo", "test", "--no-run", "--message-format=json" },
{ text = true }
):wait()
if result.code ~= 0 then
local result = vim.system(
{ "cargo", "test", "--no-run" },
{ text = true }
):wait()
vim.notify(
"Command failed:\n" .. (result.stderr or ""),
vim.log.levels.ERROR
)
end
for line in result.stdout:gmatch("[^\r\n]+") do
local ok, msg = pcall(vim.json.decode, line)
if ok and msg.executable ~= vim.NIL and msg.executable ~= nil then
return msg.executable
end
end
return nil
end
dap.configurations.rust = {
{
name = "Debug Test",
type = "rust-gdb",
request = "launch",
program = cargo_test_binary,
args = {}, -- provide arguments if needed
cwd = "${workspaceFolder}",
stopAtBeginningOfMainSubprogram = false,
},
{
name = "Launch",
type = "rust-gdb",
request = "launch",
program = function()
return vim.fn.input('Path to executable: ', vim.fn.getcwd() .. '/', 'file')
end,
args = {}, -- provide arguments if needed
cwd = "${workspaceFolder}",
stopAtBeginningOfMainSubprogram = false,
},
{
name = "Select and attach to process",
type = "rust-gdb",
request = "attach",
program = function()
return vim.fn.input('Path to executable: ', vim.fn.getcwd() .. '/', 'file')
end,
pid = function()
local name = vim.fn.input('Executable name (filter): ')
return require("dap.utils").pick_process({ filter = name })
end,
cwd = "${workspaceFolder}"
},
{
name = "Attach to gdbserver :1234",
type = "rust-gdb",
request = "attach",
target = "localhost:1234",
program = function()
return vim.fn.input('Path to executable: ', vim.fn.getcwd() .. '/', 'file')
end,
cwd = '${workspaceFolder}'
}
} }
require("dapui").setup() require("dapui").setup()
vim.keymap.set('n', '<leader>dd', require("dapui").toggle, {}) vim.keymap.set('n', '<leader>dd', require("dapui").toggle, {})
vim.keymap.set('n', '<leader>db', require("dap").toggle_breakpoint, {}) vim.keymap.set('n', '<leader>db', require("dap").toggle_breakpoint, {})
vim.keymap.set('n', '<leader>dr', function()
vim.cmd.RustLsp('debug')
end, {})
vim.fn.sign_define('DapBreakpoint', { vim.fn.sign_define('DapBreakpoint', {
text = '', text = '',
texthl = 'DapBreakpoint', texthl = 'DapBreakpoint',