mirror of
https://github.com/pratiktri/dotfiles.git
synced 2026-02-04 08:41:43 +05:30
feat(neovim-rust): Rust LSP, debugging, testing and keymaps
- `rustaceanvim` for LSP config - Rust ft specific keymaps in `after/ftplugin` - `nvim-dap` for Rust debugging with codelldb - `rustaceanvim.neotest` for Rust testing - `rcasia/neotest-bash` for Bash testing - Better keymaps for running tests - Inlay hint UI improvements
This commit is contained in:
@@ -1 +1,172 @@
|
||||
return {}
|
||||
return {
|
||||
"mfussenegger/nvim-dap",
|
||||
dependencies = {
|
||||
-- Creates a beautiful debugger UI
|
||||
"rcarriga/nvim-dap-ui",
|
||||
|
||||
-- Required dependency for nvim-dap-ui
|
||||
"nvim-neotest/nvim-nio",
|
||||
|
||||
-- Auto-installs debugger adapters
|
||||
"mason-org/mason.nvim",
|
||||
"jay-babu/mason-nvim-dap.nvim",
|
||||
|
||||
-- Shows variable values inline as virtual text
|
||||
"theHamsta/nvim-dap-virtual-text",
|
||||
},
|
||||
keys = {
|
||||
{
|
||||
"<F5>",
|
||||
function()
|
||||
require("dap").continue()
|
||||
end,
|
||||
desc = "Debug: Start/Continue",
|
||||
},
|
||||
{
|
||||
"<leader>Ds",
|
||||
function()
|
||||
require("dap").continue()
|
||||
end,
|
||||
desc = "Debug: Start/Continue",
|
||||
},
|
||||
{
|
||||
"<F11>",
|
||||
function()
|
||||
require("dap").step_into()
|
||||
end,
|
||||
desc = "Debug: Step Into",
|
||||
},
|
||||
{
|
||||
"<leader>Di",
|
||||
function()
|
||||
require("dap").step_into()
|
||||
end,
|
||||
desc = "Debug: Step Into",
|
||||
},
|
||||
{
|
||||
"<F10>",
|
||||
function()
|
||||
require("dap").step_over()
|
||||
end,
|
||||
desc = "Debug: Step Over",
|
||||
},
|
||||
{
|
||||
"<leader>Do",
|
||||
function()
|
||||
require("dap").step_over()
|
||||
end,
|
||||
desc = "Debug: Step Over",
|
||||
},
|
||||
{
|
||||
"<S-F11>",
|
||||
function()
|
||||
require("dap").step_out()
|
||||
end,
|
||||
desc = "Debug: Step Out",
|
||||
},
|
||||
{
|
||||
"<leader>DO",
|
||||
function()
|
||||
require("dap").step_out()
|
||||
end,
|
||||
desc = "Debug: Step Out",
|
||||
},
|
||||
{
|
||||
"<F9>",
|
||||
function()
|
||||
require("dap").toggle_breakpoint()
|
||||
end,
|
||||
desc = "Debug: Toggle Breakpoint",
|
||||
},
|
||||
{
|
||||
"<leader>Db",
|
||||
function()
|
||||
require("dap").toggle_breakpoint()
|
||||
end,
|
||||
desc = "Debug: Toggle Breakpoint",
|
||||
},
|
||||
{
|
||||
"<leader>DB",
|
||||
function()
|
||||
require("dap").set_breakpoint(vim.fn.input("Breakpoint condition: "))
|
||||
end,
|
||||
desc = "Debug: Set Conditional Breakpoint",
|
||||
},
|
||||
{
|
||||
"<leader>Dt",
|
||||
function()
|
||||
require("dapui").toggle()
|
||||
end,
|
||||
desc = "Debug: Toggle UI",
|
||||
},
|
||||
{
|
||||
"<leader>Dl",
|
||||
function()
|
||||
require("dap").run_last()
|
||||
end,
|
||||
desc = "Debug: Run Last Configuration",
|
||||
},
|
||||
},
|
||||
config = function()
|
||||
local dap = require("dap")
|
||||
local dapui = require("dapui")
|
||||
|
||||
-- optional
|
||||
require("mason-nvim-dap").setup({
|
||||
automatic_installation = true,
|
||||
handlers = {},
|
||||
ensure_installed = {
|
||||
"codelldb",
|
||||
},
|
||||
})
|
||||
|
||||
-- Dap UI setup
|
||||
dapui.setup({
|
||||
icons = { expanded = "▾", collapsed = "▸", current_frame = "*" },
|
||||
controls = {
|
||||
icons = {
|
||||
pause = "⏸",
|
||||
play = "▶",
|
||||
step_into = "⏎",
|
||||
step_over = "⏭",
|
||||
step_out = "⏮",
|
||||
step_back = "b",
|
||||
run_last = "▶▶",
|
||||
terminate = "⏹",
|
||||
disconnect = "⏏",
|
||||
},
|
||||
},
|
||||
})
|
||||
|
||||
-- Automatically open/close DAP UI
|
||||
dap.listeners.after.event_initialized["dapui_config"] = dapui.open
|
||||
dap.listeners.before.event_terminated["dapui_config"] = dapui.close
|
||||
dap.listeners.before.event_exited["dapui_config"] = dapui.close
|
||||
|
||||
-- Setup virtual text to show variable values inline
|
||||
require("nvim-dap-virtual-text").setup()
|
||||
|
||||
-- Setup Rust & React DAPs here
|
||||
dap.adapters.codelldb = {
|
||||
type = "server",
|
||||
port = "${port}",
|
||||
executable = {
|
||||
command = vim.fn.exepath("codelldb"),
|
||||
args = { "--port", "${port}" },
|
||||
},
|
||||
}
|
||||
|
||||
dap.configurations.rust = {
|
||||
{
|
||||
name = "Launch file",
|
||||
type = "codelldb",
|
||||
request = "launch",
|
||||
program = function()
|
||||
return vim.fn.input("Path to executable: ", vim.fn.getcwd() .. "/target/debug/", "file")
|
||||
end,
|
||||
cwd = "${workspaceFolder}",
|
||||
stopOnEntry = false,
|
||||
},
|
||||
}
|
||||
end,
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user