nvim-config-kickstart/after/plugin/mappings.lua

47 lines
2.2 KiB
Lua
Raw Normal View History

--[[
-- Contains fixes for mappings created by plugins
2023-12-24 17:03:11 +00:00
-- Useful because of bépo
--]]
-- Comments.nvim adds `gbc` command, which conflicts with `gb/gé` to move
-- between tabs
if vim.fn.maparg("gbc") ~= "" then
vim.keymap.del("n", "gbc")
vim.keymap.set('n', 'gBc', function()
2023-12-25 13:29:10 +00:00
return vim.api.nvim_get_vvar('count') == 0 and '<Plug>(comment_toggle_blockwise_current)'
or '<Plug>(comment_toggle_blockwise_count)'
end, { expr = true, desc = 'Comment toggle current block' })
end
2023-12-24 11:27:55 +00:00
-- [[ vimtex ]]
-- Some BÉPO mappings for vimtex
local texgroup = vim.api.nvim_create_augroup("latex", { clear = true })
2023-12-25 13:29:10 +00:00
vim.api.nvim_create_autocmd({ "BufEnter", "BufWinEnter" }, {
pattern = { "*.tex", "*.bib", "*.cls", "*.tikz", },
2023-12-24 11:27:55 +00:00
group = texgroup,
callback = function()
local vimtex_remaps = {
-- c <-> t
2023-12-25 13:29:10 +00:00
{ mode = "n", source = "csd", target = "tsd", command = "<Plug>(vimtex-delim-change-math)" },
{ mode = "n", source = "csc", target = "lsc", command = "<Plug>(vimtex-cmd-change)" },
{ mode = "n", source = "cse", target = "lse", command = "<Plug>(vimtex-env-change)" },
{ mode = "n", source = "cs$", target = "ls$", command = "<Plug>(vimtex-env-change-math))" },
2023-12-24 11:27:55 +00:00
-- t <-> j
2023-12-25 13:29:10 +00:00
{ mode = { "x", "n" }, source = "tsD", target = "jsD", command = "<Plug>(vimtex-delim-toggle-modifier-reverse)" },
{ mode = { "x", "n" }, source = "tsd", target = "jsd", command = "<Plug>(vimtex-delim-toggle-modifier)" },
{ mode = { "x", "n" }, source = "tsf", target = "jsf", command = "<Plug>(vimtex-cmd-toggle-frac)" },
{ mode = "n", source = "tsc", target = "jsc", command = "<Plug>(vimtex-cmd-toggle-star)" },
{ mode = "n", source = "ts$", target = "js$", command = "<Plug>(vimtex-env-toggle-math)" },
{ mode = "n", source = "tse", target = "jse", command = "<Plug>(vimtex-env-toggle-star)" },
2023-12-24 11:27:55 +00:00
}
2023-12-25 13:29:10 +00:00
for _, remap in pairs(vimtex_remaps) do
2023-12-24 11:27:55 +00:00
if vim.fn.maparg(remap.source) ~= "" then
vim.keymap.del(remap.mode, remap.source, { buffer = true })
2023-12-25 13:29:10 +00:00
vim.keymap.set(remap.mode, remap.target, remap.command, { silent = true, noremap = true, buffer = true })
2023-12-24 11:27:55 +00:00
end
end
end,
})