From b81af2dace31e2201613f3ebecd46f2544883d2b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment=20Joly?= Date: Sat, 7 May 2022 20:06:08 +0000 Subject: [PATCH] =?UTF-8?q?fix:=20g=C3=A9=20and=20gB=20mappings?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- fnl/bepo.fnl | 12 +++++++++--- lua/bepo.lua | 15 ++++++++++++--- 2 files changed, 21 insertions(+), 6 deletions(-) diff --git a/fnl/bepo.fnl b/fnl/bepo.fnl index 52ba878..0602438 100644 --- a/fnl/bepo.fnl +++ b/fnl/bepo.fnl @@ -13,6 +13,7 @@ ;; See the License for the specific language governing permissions and ;; limitations under the License. ;; +;; Credit: Inspired by https://github.com/michamos/vim-bepo by Micha Moskovic (fn map-text-object [key target] "For text-objects mappings" @@ -28,7 +29,7 @@ (vim.api.nvim_set_keymap :n key target {:noremap true}) (map-text-object key target))) -(fn setup [] +(fn mapping-setup [] ;; Keys still free ;; , and ; as they may be used as leaders ;; à and À @@ -73,9 +74,9 @@ ;; 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 :) + (map-all :gB ":execute \"silent! tabfirst\"") ;; [gB] va au premier tab - (map-all "gÉ" ":execute " silent! tablast " ") + (map-all "gÉ" ":execute \"silent! tablast\"") ;; [gÉ] au dernier (map-all :gT "") ;; [gT] est libéré et peut agir sur les tags @@ -131,5 +132,10 @@ ;; déplace sur un nouveau tab ) +(fn setup [] + (when (= vim.g.loaded_bepo_nvim nil) + (mapping-setup) + (set vim.g.loaded_bepo_nvim 1))) + {: setup} diff --git a/lua/bepo.lua b/lua/bepo.lua index 3089bff..39d6437 100644 --- a/lua/bepo.lua +++ b/lua/bepo.lua @@ -14,7 +14,7 @@ local function map_all(key, target) return map_text_object(key, target) end end -local function setup() +local function mapping_setup() map_all("c", "h") map_all("t", "j") map_all("s", "k") @@ -35,8 +35,8 @@ local function setup() 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("gB", ":execute \"silent! tabfirst\"") + map_all("g\195\137", ":execute \"silent! tablast\"") map_all("gT", "") map_all("\194\171", "<") map_all("\194\187", ">") @@ -62,4 +62,13 @@ local function setup() map_all("w\195\169", "t") return map_all("w\195\137", "T") end +local function setup() + if (vim.g.loaded_bepo_nvim == nil) then + mapping_setup() + vim.g.loaded_bepo_nvim = 1 + return nil + else + return nil + end +end return {setup = setup}