From 3aca44bf20407e9cf9467224bec6a57bee9cc110 Mon Sep 17 00:00:00 2001 From: Fabrice Mouhartem Date: Sun, 24 Dec 2023 00:01:01 +0100 Subject: [PATCH] =?UTF-8?q?Add=20b=C3=A9po=20mappings?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- init.lua | 2 ++ lua/bepo.lua | 72 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 74 insertions(+) create mode 100644 lua/bepo.lua diff --git a/init.lua b/init.lua index ac7784c..7f02508 100644 --- a/init.lua +++ b/init.lua @@ -620,5 +620,7 @@ cmp.setup { }, } +-- Personnalisation +require('bepo') -- The line beneath this is called `modeline`. See `:help modeline` -- vim: ts=2 sts=2 sw=2 et diff --git a/lua/bepo.lua b/lua/bepo.lua new file mode 100644 index 0000000..7fd1f46 --- /dev/null +++ b/lua/bepo.lua @@ -0,0 +1,72 @@ +-- colorise les nbsp +-- highlight NbSp ctermbg=lightgray guibg=lightred +--hi NbSps ctermbg=lightred guibg=lightred +--match NbSps /\%xa0\|\%u202F/ +-- bépo +vim.opt.listchars:append({nbsp = "·", trail = "¤"}) +vim.opt.list = true + +-- ii devient Esc +vim.api.nvim_set_keymap('i', 'ii', '', {noremap = true, silent = true}) +-- Y pour copier dans le presse papier +vim.api.nvim_set_keymap('', 'Y', '"+y', {}) + +-- {W} -> [É] +-- —————————— +-- On remappe W sur É : +-- Pour faciliter les manipulations de fenêtres, on utilise {W} comme un Ctrl+W : +local keymap = vim.keymap.set +local opts = {noremap = true, silent = true} + +local map_list = {['é'] = 'w', ['É'] = 'W', ['w'] = ''} +for key,binding in pairs(map_list) do + keymap('n', key, binding, opts) +end +-- Corollaire: on remplace les text objects aw, aW, iw et iW +-- pour effacer/remplacer un mot quand on n’est pas au début (daé / laé). +local omap_list = {['aé'] = 'w', ['aÉ'] = 'aW', ['ié'] = 'iw', ['iÉ'] = 'iW'} +for key,binding in pairs(omap_list) do + keymap('o', key, binding, opts) +end + +-- [HJKL] <-> {CTSR} +-- ———————————————— +map_list = { + ['c'] = 'h', ['r'] = 'l', ['t'] = 'j', ['s'] = 'k', ['C'] = 'H', ['R'] = 'L', ['T'] = 'J', ['S'] = 'K', -- [HJKL] -> [CTSR] + ['j'] = 't', ['J'] = 'T', ['l'] = 'c', ['L'] = 'C', ['h'] = 'r', ['H'] = 'R', ['k'] = 's', ['K'] = 'S', -- [CTSR] -> [HJKL]: J = jusqu'à, L = change, h = remplace, k = substitute + ['zs'] = 'zj', ['zt'] = 'zk', -- Pour les replis + [']k'] = ']s', ['[k'] = '[s' , -- correction orthographique +} +for key, binding in pairs(map_list) do + keymap({'n', 'x'}, key, binding, opts) +end + +-- Désambiguation de {g} +-- ————————————————————— +-- ligne écran précédente / suivante (à l'intérieur d'une phrase) +-- onglets précédent/suivant : gé/gb, premier/dernier onglet : gÉ/gB, +-- g" = première ligne de l’écran +local map_list = {['gs'] = 'gk', ['gt'] = 'gj', ['gb'] = 'gT', ['gé'] = 'gt', ['gB'] = ':tabfirst', ['gÉ'] = ':tablast', ['g"'] = 'g0', } +for key, binding in pairs(map_list) do + keymap({'n', 'x'}, key, binding, opts) +end + +-- <> en direct +-- ———————————— +vim.api.nvim_set_keymap('', '«', '<', {noremap = false, silent = true}) +vim.api.nvim_set_keymap('', '»', '>', {noremap = false, silent = true}) + +-- Chiffres en accès direct +-- ———————————————————————— +-- À décommenter si on souhaite les avoir +--local map_list = { ['"'] = '1', ['1'] = '"', ['«'] = '2', ['2'] = '<', ['»'] = '3', ['3'] = '>', ['('] = '4', ['4'] = '(', [')'] = '5', ['5'] = ')', ['@'] = '6', ['6'] = '@', ['+'] = '7', ['7'] = '+', ['-'] = '8', ['8'] = '-', ['/'] = '9', ['9'] = '/', ['*'] = '0', ['0'] = '*', } +--for key, binding in pairs(map_list) do +-- vim.api.nvim_set_keymap('', key, binding, { noremap = true, silent = true }) +--end + +-- Remaper la gestion des fenêtres +-- ——————————————————————————————— +map_list = {['wt'] = 'j', ['ws'] = 'k', ['wc'] = 'h', ['wr'] = 'l', ['wd'] = 'c', ['wo'] = 's', ['wp'] = 'o', ['w'] = ':split', ['w'] = ':vsplit', [''] = '', } +for key, binding in pairs(map_list) do + vim.api.nvim_set_keymap('', key, binding, {noremap = true, silent = true}) +end