plugins: better compatability with nullable keybinds

Mostly involves filtering keybinds that are null in cases where the
keybind is the attrname, and optionalString for manual lua keybind
registration.
This commit is contained in:
alfarel 2026-03-14 22:18:05 -04:00
commit f040b4a943
No known key found for this signature in database
8 changed files with 185 additions and 155 deletions

View file

@ -214,24 +214,31 @@ in {
on_attach = function(client, bufnr)
default_on_attach(client, bufnr)
local opts = { noremap=true, silent=true, buffer = bufnr }
vim.keymap.set("n", "<localleader>rr", ":RustLsp runnables<CR>", opts)
vim.keymap.set("n", "<localleader>rp", ":RustLsp parentModule<CR>", opts)
vim.keymap.set("n", "<localleader>rm", ":RustLsp expandMacro<CR>", opts)
vim.keymap.set("n", "<localleader>rc", ":RustLsp openCargo", opts)
vim.keymap.set("n", "<localleader>rg", ":RustLsp crateGraph x11", opts)
${optionalString cfg.dap.enable ''
${optionalString config.vim.vendoredKeymaps ''
vim.keymap.set("n", "<localleader>rr", ":RustLsp runnables<CR>", opts)
vim.keymap.set("n", "<localleader>rp", ":RustLsp parentModule<CR>", opts)
vim.keymap.set("n", "<localleader>rm", ":RustLsp expandMacro<CR>", opts)
vim.keymap.set("n", "<localleader>rc", ":RustLsp openCargo", opts)
vim.keymap.set("n", "<localleader>rg", ":RustLsp crateGraph x11", opts)
''}
${optionalString (cfg.dap.enable && config.vim.vendoredKeymaps) ''
vim.keymap.set("n", "<localleader>rd", ":RustLsp debuggables<cr>", opts)
''}
${optionalString (cfg.dap.enable && config.vim.debugger.nvim-dap.mappings.continue != null) ''
vim.keymap.set(
"n", "${config.vim.debugger.nvim-dap.mappings.continue}",
function()
local dap = require("dap")
if dap.status() == "" then
vim.cmd "RustLsp debuggables"
else
dap.continue()
end
end,
opts
"n", "${config.vim.debugger.nvim-dap.mappings.continue}",
function()
local dap = require("dap")
if dap.status() == "" then
vim.cmd "RustLsp debuggables"
else
dap.continue()
end
end,
opts
)
''}
end

View file

@ -117,7 +117,9 @@ in {
local attach_metals_keymaps = function(client, bufnr)
attach_keymaps(client, bufnr) -- from lsp-setup
${optionalString (cfg.lsp.extraMappings.listCommands != null) ''
vim.api.nvim_buf_set_keymap(bufnr, 'n', '${cfg.lsp.extraMappings.listCommands}', '<cmd>lua ${listCommandsAction}<CR>', {noremap=true, silent=true, desc='Show all Metals commands'})
''}
end
metals_config = require('metals').bare_config()