From f4fde90367fa8f05256d613a2522c0d603b95629 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment=20Joly?= Date: Sat, 7 May 2022 19:29:46 +0000 Subject: [PATCH] Initial import from michamos/vim-bepo --- Readme.md | 2 + fnl/bepo.fnl | 110 +++++++++++++++++++++++++++++++++++++++++++++++++-- lua/bepo.lua | 53 +++++++++++++++++++++++-- 3 files changed, 157 insertions(+), 8 deletions(-) diff --git a/Readme.md b/Readme.md index 40c0b31..0d28a16 100644 --- a/Readme.md +++ b/Readme.md @@ -1,3 +1,5 @@ # bepo.nvim *Work in progress* + +Remap for the bepo layout in Lua, inspired from https://github.com/michamos/vim-bepo diff --git a/fnl/bepo.fnl b/fnl/bepo.fnl index aa85f28..4f15029 100644 --- a/fnl/bepo.fnl +++ b/fnl/bepo.fnl @@ -16,20 +16,122 @@ (fn map-text-object [key target] "For text-objects mappings" - (if (= (vim.fn.maprg key :o) "") + (if (= (vim.fn.maparg key :o) "") (vim.api.nvim_set_keymap :o key target {:noremap true}) - (= (vim.fn.maprg key :x) "") + (= (vim.fn.maparg key :x) "") (vim.api.nvim_set_keymap :x key target {:noremap true})) nil) (fn map-all [key target] "For everything else" - (if (= (vim.fn.maprg key :n) "") + (if (= (vim.fn.maparg key :n) "") (vim.api.nvim_set_keymap :n key target {:noremap true}) (map-text-object key target))) (fn setup [] - (map-all :c :h)) + ;; Keys still free + ;; , and ; as they may be used as leaders + ;; à and À + ;; on préserve {hjkl} pour les directions + (map-all :c :h) + (map-all :t :j) + (map-all :s :k) + (map-all :r :l) + (map-all :C :H) + ;; ------ + ;; {HJKL} devient [CTSR] + (map-all :T :J) + ;; {HJKL} devient [CTSR] + (map-all :S :K) + ;; {HJKL} devient [CTSR] + ;; (map-all "R" "L") ;; {HJKL} devient [CTSR] -> free R + ;; ------ + ;; on préserve les variantes avec 'g' + (map-all :gt :gj) + (map-all :gs :gk) + ;; ------ + ;; on préserve les variantes avec 'z' + ;; I like zt better + ;; (map-all "zt" "zj") + (map-all :zs :zk) + ;; ------ + (map-all :h :t) + ;; {t} devient [h] pour être proche de [f] + (map-all :H :T) + ;; idem pour {T} et [H] + (map-all :l :c) + ;; {c} devient [l] + (map-all :L :C) + ;; {C} devient [L] + (map-all :j :r) + ;; {j} devient [r] + (map-all :J :R) + ;; {J} devient [R] + (map-all :k :s) + ;; {k} devient [s] + (map-all :K :S) + ;; {h} devient [S] + (map-all :gb :gT) + ;; le couple [gb]/[gé] agit sur les tabs + (map-all "gé" :gt) + ;; le couple [gb]/[gé] agit sur les tabs + (map-all :gB ":execute " silent! tabfirst :) + ;; [gB] va au premier tab + (map-all "gÉ" ":execute " silent! tablast " ") + ;; [gÉ] au dernier + (map-all :gT "") + ;; [gT] est libéré et peut agir sur les tags + (map-all "«" "<") + ;; [<] est moins accessible que [«] + (map-all "»" ">") + ;; idem pour [»] et [>] + (map-all "g," "g;") + ;; idem pour [g,] et [g;] + (map-all "g;" "g,") + ;; qui sont permutés + (map-all "é" :w) + ;; [w] est peu accessible, on utilise [é] + (map-all "É" :W) + ;; idem pour [W] et [É] + ;; ------ + (map-text-object "aé" :aw) + ;; idem pour [aw] et [aé] + (map-text-object "aÉ" :aW) + ;; idem pour [aW] et [aÉ] + (map-text-object "ié" :iw) + ;; idem pour [iw] et [ié] + (map-text-object "iÉ" :iW) + ;; idem pour [iW] et [iÉ] + ;; ------ + (map-all :w :) + ;; [w] est libre pour faire + (map-all :W :) + ;; et [w] pour faire + (map-all :wc :h) + ;; on map [w]+direction + (map-all :wt :j) + ;; on map [w]+direction + (map-all :ws :k) + ;; on map [w]+direction + (map-all :wr :l) + ;; on map [w]+direction + (map-all :wC :H) + ;; idem pour les majuscules + (map-all :wT :J) + ;; idem pour les majuscules + (map-all :wS :K) + ;; idem pour les majuscules + (map-all :wR :L) + ;; idem pour les majuscules + ;; ------ + (map-all :wh :s) + ;; crée un split _h_orizontal + ;; ------ + (map-all "wé" :t) + ;; va en haut à gauche + (map-all "wÉ" :T) + ;; déplace sur un nouveau tab + ) {: setup} diff --git a/lua/bepo.lua b/lua/bepo.lua index f570ec1..3089bff 100644 --- a/lua/bepo.lua +++ b/lua/bepo.lua @@ -1,20 +1,65 @@ local function map_text_object(key, target) - if (vim.fn.maprg(key, "o") == "") then + if (vim.fn.maparg(key, "o") == "") then vim.api.nvim_set_keymap("o", key, target, {noremap = true}) - elseif (vim.fn.maprg(key, "x") == "") then + elseif (vim.fn.maparg(key, "x") == "") then vim.api.nvim_set_keymap("x", key, target, {noremap = true}) else end return nil end local function map_all(key, target) - if (vim.fn.maprg(key, "n") == "") then + if (vim.fn.maparg(key, "n") == "") then return vim.api.nvim_set_keymap("n", key, target, {noremap = true}) else return map_text_object(key, target) end end local function setup() - return map_all("c", "h") + map_all("c", "h") + map_all("t", "j") + map_all("s", "k") + map_all("r", "l") + map_all("C", "H") + map_all("T", "J") + map_all("S", "K") + map_all("gt", "gj") + map_all("gs", "gk") + map_all("zs", "zk") + map_all("h", "t") + map_all("H", "T") + map_all("l", "c") + map_all("L", "C") + map_all("j", "r") + map_all("J", "R") + map_all("k", "s") + map_all("K", "S") + map_all("gb", "gT") + map_all("g\195\169", "gt") + map_all("gB", ":execute ", __fnl_global__silent_21, tabfirst, "") + map_all("g\195\137", ":execute ", __fnl_global__silent_21, tablast, " ") + map_all("gT", "") + map_all("\194\171", "<") + map_all("\194\187", ">") + map_all("g,", "g;") + map_all("g;", "g,") + map_all("\195\169", "w") + map_all("\195\137", "W") + map_text_object("a\195\169", "aw") + map_text_object("a\195\137", "aW") + map_text_object("i\195\169", "iw") + map_text_object("i\195\137", "iW") + map_all("w", "") + map_all("W", "") + map_all("wc", "h") + map_all("wt", "j") + map_all("ws", "k") + map_all("wr", "l") + map_all("wC", "H") + map_all("wT", "J") + map_all("wS", "K") + map_all("wR", "L") + map_all("wh", "s") + map_all("w\195\169", "t") + return map_all("w\195\137", "T") end return {setup = setup}