diff --git a/after/plugin/mappings.lua b/after/plugin/mappings.lua index f1b6198..c6ebb29 100644 --- a/after/plugin/mappings.lua +++ b/after/plugin/mappings.lua @@ -11,3 +11,35 @@ if vim.fn.maparg("gbc") ~= "" then or '(comment_toggle_blockwise_count)' end, { expr = true, desc = 'Comment toggle current block' }) end + +-- [[ vimtex ]] +-- Some BÉPO mappings for vimtex +local texgroup = vim.api.nvim_create_augroup("latex", { clear = true }) + +vim.api.nvim_create_autocmd({"BufEnter", "BufWinEnter"}, { + pattern = {"*.tex", "*.bib", "*.cls", "*.tikz", }, + group = texgroup, + callback = function() + local vimtex_remaps = { + -- c <-> t + { mode = "n", source = "csd", target = "tsd", command = "(vimtex-delim-change-math)"}, + { mode = "n", source = "csc", target = "lsc", command = "(vimtex-cmd-change)"}, + { mode = "n", source = "cse", target = "lse", command = "(vimtex-env-change)"}, + { mode = "n", source = "cs$", target = "ls$", command = "(vimtex-env-change-math))"}, + -- t <-> j + { mode = {"x", "n"}, source = "tsD", target = "jsD", command = "(vimtex-delim-toggle-modifier-reverse)"}, + { mode = {"x", "n"}, source = "tsd", target = "jsd", command = "(vimtex-delim-toggle-modifier)"}, + { mode = {"x", "n"}, source = "tsf", target = "jsf", command = "(vimtex-cmd-toggle-frac)"}, + { mode = "n", source = "tsc", target = "jsc", command = "(vimtex-cmd-toggle-star)"}, + { mode = "n", source = "ts$", target = "js$", command = "(vimtex-env-toggle-math)"}, + { mode = "n", source = "tse", target = "jse", command = "(vimtex-env-toggle-star)"}, + } + + for _,remap in pairs(vimtex_remaps) do + if vim.fn.maparg(remap.source) ~= "" then + vim.keymap.del(remap.mode, remap.source, { buffer = true }) + vim.keymap.set(remap.mode, remap.target, remap.command, { silent = true, noremap = true, buffer = true}) + end + end + end, +})