dotfiles/ftplugin/rust.lua
Gered 9bb4d876a4 change rust run & debug keymaps to use previous target (when available)
this might prove annoying at some point, but i figure this is by far
the most common way i would use these (to re-run/re-debug the same
target as i'm working and in between changes, etc)
2024-09-03 17:41:07 -04:00

19 lines
937 B
Lua

local bufnr = vim.api.nvim_get_current_buf()
local function map(mode, lhs, rhs, opts)
opts = opts or {}
opts.buffer = bufnr
opts.silent = true
vim.keymap.set(mode, lhs, rhs, opts)
end
map('n', '<leader>ra', '<Cmd>RustLsp codeAction<CR>', { desc = 'Code [A]ction' })
map('n', '<leader>rr', '<Cmd>RustLsp! runnables<CR>', { desc = '[R]un' })
map('n', '<leader>rR', '<Cmd>RustLsp runnables<CR>', { desc = '[R]unnables' })
map('n', '<leader>rd', '<Cmd>RustLsp! debuggables<CR>', { desc = '[D]ebug' })
map('n', '<leader>rD', '<Cmd>RustLsp debuggables<CR>', { desc = '[D]ebuggables' })
map('n', '<leader>rt', '<Cmd>RustLsp testables<CR>', { desc = '[T]estables' })
map('n', '<leader>re', '<Cmd>RustLsp explainError<CR>', { desc = '[E]xplain Error' })
map('n', '<leader>ri', '<Cmd>RustLsp renderDiagnostic<CR>', { desc = 'Show Next D[i]agnostic' })
map('n', '<leader>ro', '<Cmd>RustLsp openCargo<CR>', { desc = '[O]pen Cargo.toml' })