Compare commits

..

1 Commits

Author SHA1 Message Date
Clément Joly
bbce509a37 feat: attempt to use macro in fennel to improve preformance
That seems to mess up the JIT optimisations, so doing that is actually
slower.
2022-11-13 13:01:21 +00:00
7 changed files with 284 additions and 284 deletions

View File

@ -13,6 +13,9 @@ tags:
- Bepo - Bepo
- Lisp - Lisp
- Fennel - Fennel
#images:
#- /telescope-repo-nvim/opengraph.png
#- /telescope-repo-nvim/opengraph.webp
--- ---
{{< github_badge >}} {{< github_badge >}}
@ -24,7 +27,7 @@ end_insert -->
# ⌨️ bepo.nvim # ⌨️ bepo.nvim
<!-- end_remove --> <!-- end_remove -->
![Neovim version](https://img.shields.io/badge/Neovim-0.5-57A143?style=flat&logo=neovim) [![](https://img.shields.io/badge/powered%20by-riss-lightgrey)](https://cj.rs/riss) ![GitHub tag (latest SemVer)](https://img.shields.io/github/v/tag/cljoly/bepo.nvim?color=darkgreen&sort=semver) ![Endpoint Badge](https://img.shields.io/endpoint?url=https%3A%2F%2Fd.cj.rs%2Fnvim%2Fbepo.json&cacheSeconds=90000) ![Neovim version](https://img.shields.io/badge/Neovim-0.5-57A143?style=flat&logo=neovim) [![](https://img.shields.io/badge/powered%20by-riss-lightgrey)](https://cj.rs/riss) ![GitHub tag (latest SemVer)](https://img.shields.io/github/v/tag/cljoly/bepo.nvim?color=darkgreen&sort=semver)
<!-- insert <!-- insert
{{< rawhtml >}} {{< rawhtml >}}
@ -36,32 +39,13 @@ Mappings for the [bepo][] layout in Lua, inspired by [vim-bepo][vb]
It aims to be faster (takes only 0.4ms at startup on my machine, while [vim-bepo][vb] requires 1.6ms) and more customizable (see `:help bepo.nvim-cherry-pick`) It aims to be faster (takes only 0.4ms at startup on my machine, while [vim-bepo][vb] requires 1.6ms) and more customizable (see `:help bepo.nvim-cherry-pick`)
## Installation ## Example Use
Add the plugin `cljoly/bepo.nvim` to your package manager. You should call the extension early in your config, so that you can erase mappings later (or with later extensions) more easily.
If you dont have a package manager yet, I use [paq.nvim][paq].
You can give it a try :).
Look at the [installation instructions][paq_install] and then add the following to your config:
```lua
require "paq" {
"cljoly/bepo.nvim",
-- ... other packages
}
```
Then restart neovim and run `PaqInstall`. That will install the bepo.nvim plugin.
## Usage
Once the plugin is installed, you can add a call to set up the bepo mappings to your config:
``` lua ``` lua
require("bepo").setup() require("bepo").setup()
``` ```
You should call the extension early in your `init.lua`, so that you can erase mappings later (or with other extensions) more easily.
## Advanced Usage
You can also apply only some mapping groups: You can also apply only some mapping groups:
``` lua ``` lua
@ -73,24 +57,6 @@ require("bepo").window()
See [the help file][help] for more details and the mappings installed. See [the help file][help] for more details and the mappings installed.
## Reporting bugs
Thanks for considering reporting a bug!
We want to know if the issue is caused by:
1. the plugin itself
2. your user configuration
3. the system configuration
Please try to reproduce the bug in nvim stripped of your user configuration by running:
```
nvim --clean -u test/mock_setup.lua
```
If you cant reproduce the bug in that “clean” nvim instance, it suggests that the bug comes from an interaction of the plugin with your user configuration. Please feel free to open an issue, mentioning that.
[bepo]: https://bepo.fr/
[help]: https://github.com/cljoly/bepo.nvim/blob/main/doc/bepo-nvim.txt
[paq]: https://github.com/savq/paq-nvim
[paq_install]: https://github.com/savq/paq-nvim?tab=readme-ov-file#installation
[vb]: https://github.com/michamos/vim-bepo [vb]: https://github.com/michamos/vim-bepo
[help]: https://github.com/cljoly/bepo.nvim/blob/main/doc/bepo-nvim.txt
[bepo]: https://bepo.fr/

View File

@ -43,14 +43,33 @@ only the “window” and “movement” groups of mapping, use this instead of
The following subsections go into details of exactly what mappings are The following subsections go into details of exactly what mappings are
in each group. “Modes” have the same meaning as in the |map-table|. in each group. “Modes” have the same meaning as in the |map-table|.
--------------------------------------------------------------------------------
require("bepo").window() *bepo.nvim-window*
[w] est libre pour faire <C-w>, grâce à easy_access
Modes Bepo Qwerty
n w <C-w>
n W <C-w><C-w>
n wc <C-w>h
n wt <C-w>j
n ws <C-w>k
n wr <C-w>l
n wC <C-w>H
n wT <C-w>J
n wS <C-w>K
n wR <C-w>L
n wh <C-w>s
n wé <C-w>t
n wÉ <C-w>T
-------------------------------------------------------------------------------- --------------------------------------------------------------------------------
require("bepo").easy_access() *bepo.nvim-easy_access* require("bepo").easy_access() *bepo.nvim-easy_access*
Modes Bepo Qwerty Modes Bepo Qwerty
n « < n « <
x « <gv v « <gv
n » > n » >
x » >gv v » >gv
nx g, g; nx g, g;
nx g; g, nx g; g,
nx é w nx é w
@ -60,6 +79,17 @@ require("bepo").easy_access() *bepo.nvim-easy_acces
ox ié iw ox ié iw
ox iÉ iW ox iÉ iW
--------------------------------------------------------------------------------
require("bepo").tabs() *bepo.nvim-tabs*
le couple [gb]/[gé] agit sur les tabs
Modes Bepo Qwerty
n gb gT
n gé gt
n gB :execute "silent! tabfirst"<CR>
n gÉ :execute "silent! tablast"<CR>
n gT <C-]>
-------------------------------------------------------------------------------- --------------------------------------------------------------------------------
require("bepo").movement() *bepo.nvim-movement* require("bepo").movement() *bepo.nvim-movement*
on préserve {hjkl} pour les directions on préserve {hjkl} pour les directions
@ -88,35 +118,5 @@ on préserve {hjkl} pour les directions
nx k s nx k s
nx K S nx K S
--------------------------------------------------------------------------------
require("bepo").tabs() *bepo.nvim-tabs*
le couple [gb]/[gé] agit sur les tabs
Modes Bepo Qwerty
n gb gT
n gé gt
n gB :execute "silent! tabfirst"<CR>
n gÉ :execute "silent! tablast"<CR>
n gT <C-]>
--------------------------------------------------------------------------------
require("bepo").window() *bepo.nvim-window*
[w] est libre pour faire <C-w>, grâce à easy_access
Modes Bepo Qwerty
n w <C-w>
n W <C-w><C-w>
n wc <C-w>h
n wt <C-w>j
n ws <C-w>k
n wr <C-w>l
n wC <C-w>H
n wT <C-w>J
n wS <C-w>K
n wR <C-w>L
n wh <C-w>s
n wé <C-w>t
n wÉ <C-w>T
vim:tw=78:ts=8:ft=help:norl: vim:tw=78:ts=8:ft=help:norl:

View File

@ -1,10 +0,0 @@
!_TAG_FILE_ENCODING utf-8 //
bepo.nvim bepo-nvim.txt /*bepo.nvim*
bepo.nvim-always-free bepo-nvim.txt /*bepo.nvim-always-free*
bepo.nvim-cherry-pick bepo-nvim.txt /*bepo.nvim-cherry-pick*
bepo.nvim-easy_access bepo-nvim.txt /*bepo.nvim-easy_access*
bepo.nvim-movement bepo-nvim.txt /*bepo.nvim-movement*
bepo.nvim-setup bepo-nvim.txt /*bepo.nvim-setup*
bepo.nvim-tabs bepo-nvim.txt /*bepo.nvim-tabs*
bepo.nvim-usage bepo-nvim.txt /*bepo.nvim-usage*
bepo.nvim-window bepo-nvim.txt /*bepo.nvim-window*

View File

@ -1,5 +1,4 @@
;;; bepo.nvim: bepo mapping for neovim ;;; bepo.nvim: bepo mapping for neovim
;; Copyright 2022 Clément Joly ;; Copyright 2022 Clément Joly
;; ;;
;; Licensed under the Apache License, Version 2.0 (the "License"); ;; Licensed under the Apache License, Version 2.0 (the "License");
@ -16,37 +15,38 @@
;; ;;
;; Credit: Inspired by https://github.com/michamos/vim-bepo by Micha Moskovic ;; Credit: Inspired by https://github.com/michamos/vim-bepo by Micha Moskovic
(fn map-text-object [key target] (macro map-text-object [key target]
"For text-objects mappings" "For text-objects mappings"
(vim.api.nvim_set_keymap :o key target {:noremap true}) `(do
(vim.api.nvim_set_keymap :x key target {:noremap true}) (vim.api.nvim_set_keymap :o ,key ,target {:noremap true})
nil) (vim.api.nvim_set_keymap :x ,key ,target {:noremap true})
nil))
(fn map-visual [key target] (macro map-visual [key target]
"For visual mode mappings"
(vim.api.nvim_set_keymap :x key target {:noremap true})
nil)
(fn map-normal [key target]
"For normal mode mappings" "For normal mode mappings"
(vim.api.nvim_set_keymap :n key target {:noremap true}) `(vim.api.nvim_set_keymap :v ,key ,target {:noremap true}))
nil)
(fn map-all [key target] (macro map-normal [key target]
"For normal mode mappings"
`(vim.api.nvim_set_keymap :n ,key ,target {:noremap true}))
(macro map-all [key target]
"For all directional mappings" "For all directional mappings"
(map-normal key target) `(do
(map-text-object key target)) (map-normal ,key ,target)
(map-text-object ,key ,target)
nil))
(macro def-documented [...] (macro 𝛅 [...]
"When called with the right context, this will print the documentation of the "When called with the right context, this will print the documentation of the
mappings, instead of attempting to bind. Since we access _G, this needs to be mappings, instead of attempting to bind. Since we access _G, this needs to be
called with --no-compiler-sandbox (see called with --no-compiler-sandbox (see
https://fennel-lang.org/reference#compiler-environment)" https://fennel-lang.org/reference#compiler-environment)"
(fn fun-to-mods [fun] (fn fun-to-mods [fun]
"Converts a function to the modes it sets mappings for" "Converts a function to the modes it sets mappings for"
(case (tostring fun) (match (tostring fun)
:map-text-object :ox :map-text-object :ox
:map-visual :x :map-visual :v
:map-normal :n :map-normal :n
:map-all :nx :map-all :nx
other (error (.. "Unsupported function " other)))) other (error (.. "Unsupported function " other))))
@ -69,99 +69,56 @@
`(local ,doc-struct.fname ,doc-struct)) `(local ,doc-struct.fname ,doc-struct))
`(fn ,(unpack [...])))) `(fn ,(unpack [...]))))
(def-documented mapping-movement [] (𝛅 mapping-movement [] "on préserve {hjkl} pour les directions"
"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) (map-all :C :H) ;; ------
(map-all :t :j) ;; {JKL} devient [TSR]
(map-all :s :k) (map-all :T :J) (map-all :S :K) (map-all :R :L) ;; ------
(map-all :r :l) ;; on préserve les variantes avec 'g'
(map-all :C :H) (map-all :gt :gj) (map-all :gs :gk) ;; ------
;; ------ ;; on préserve les variantes avec 'z'
;; {JKL} devient [TSR] (map-all :zT :zt) (map-all :zt :zj) (map-all :zk :zs) (map-all :zs :zk)
(map-all :T :J) ;; ------
(map-all :S :K) ;; {t} devient [h] pour être proche de [f]
(map-all :R :L) (map-all :h :t) ;; idem pour {T} et [H]
;; ------ (map-all :H :T) ;; {c} devient [l]
;; on préserve les variantes avec 'g' (map-all :l :c) ;; {C} devient [L]
(map-all :gt :gj) (map-all :L :C) ;; {j} devient [r]
(map-all :gs :gk) (map-all :j :r) ;; {J} devient [R]
;; ------ (map-all :J :R) ;; {k} devient [s]
;; on préserve les variantes avec 'z' (map-all :k :s) ;; {K} devient [S]
(map-all :zT :zt) (map-all :K :S))
(map-all :zt :zj)
(map-all :zk :zs)
(map-all :zs :zk)
;; ------
;; {t} devient [h] pour être proche de [f]
(map-all :h :t)
;; idem pour {T} et [H]
(map-all :H :T)
;; {c} devient [l]
(map-all :l :c)
;; {C} devient [L]
(map-all :L :C)
;; {j} devient [r]
(map-all :j :r)
;; {J} devient [R]
(map-all :J :R)
;; {k} devient [s]
(map-all :k :s)
;; {K} devient [S]
(map-all :K :S))
(def-documented mapping-tabs [] (𝛅 mapping-tabs [] "le couple [gb]/[gé] agit sur les tabs"
"le couple [gb]/[gé] agit sur les tabs" (map-normal :gb :gT) (map-normal "gé" :gt) ;; [gB] va au premier tab
(map-normal :gb :gT) (map-normal :gB ":execute \"silent! tabfirst\"<CR>") ;; [gÉ] au dernier
(map-normal "gé" :gt) (map-normal "gÉ" ":execute \"silent! tablast\"<CR>")
;; [gB] va au premier tab ;; [gT] est libéré et peut agir sur les tags
(map-normal :gB ":execute \"silent! tabfirst\"<CR>") (map-normal :gT "<C-]>"))
;; [gÉ] au dernier
(map-normal "gÉ" ":execute \"silent! tablast\"<CR>")
;; [gT] est libéré et peut agir sur les tags
(map-normal :gT "<C-]>"))
(def-documented mapping-easy-access [] ;; [<] est moins accessible que [«] (𝛅 mapping-easy-access [] ;; [<] est moins accessible que [«]
(map-normal "«" "<") (map-normal "«" "<") (map-visual "«" :<gv) ;; idem pour [»] et [>]
(map-visual "«" :<gv) (map-normal "»" ">") (map-visual "»" :>gv)
;; idem pour [»] et [>] ;; idem pour [g,] et [g;] qui sont permutés
(map-normal "»" ">") (map-all "g," "g;") (map-all "g;" "g,")
(map-visual "»" :>gv) ;; [w] est peu accessible, on utilise [é]
;; idem pour [g,] et [g;] qui sont permutés (map-all "é" :w) ;; idem pour [W] et [É]
(map-all "g," "g;") (map-all "É" :W) ;; idem pour [aw] et [aé]
(map-all "g;" "g,") (map-text-object "aé" :aw) ;; idem pour [aW] et [aÉ]
;; [w] est peu accessible, on utilise [é] (map-text-object "aÉ" :aW) ;; idem pour [iw] et [ié]
(map-all "é" :w) (map-text-object "ié" :iw) ;; idem pour [iW] et [iÉ]
;; idem pour [W] et [É] (map-text-object "iÉ" :iW))
(map-all "É" :W)
;; idem pour [aw] et [aé]
(map-text-object "aé" :aw)
;; idem pour [aW] et [aÉ]
(map-text-object "aÉ" :aW)
;; idem pour [iw] et [ié]
(map-text-object "ié" :iw)
;; idem pour [iW] et [iÉ]
(map-text-object "iÉ" :iW))
(def-documented mapping-window [] (𝛅 mapping-window [] "[w] est libre pour faire <C-w>, grâce à easy_access"
"[w] est libre pour faire <C-w>, grâce à easy_access" (map-normal :w :<C-w>) ;; et [w] pour faire <C-w><C-w>
(map-normal :w :<C-w>) (map-normal :W :<C-w><C-w>) ;; on map [w]+direction, miniscule + majuscule
;; et [w] pour faire <C-w><C-w> (map-normal :wc :<C-w>h) (map-normal :wt :<C-w>j) (map-normal :ws :<C-w>k)
(map-normal :W :<C-w><C-w>) (map-normal :wr :<C-w>l) (map-normal :wC :<C-w>H) (map-normal :wT :<C-w>J)
;; on map [w]+direction, miniscule + majuscule (map-normal :wS :<C-w>K) (map-normal :wR :<C-w>L)
(map-normal :wc :<C-w>h) ;; crée un split _h_orizontal
(map-normal :wt :<C-w>j) (map-normal :wh :<C-w>s) ;; va en haut à gauche
(map-normal :ws :<C-w>k) (map-normal "wé" :<C-w>t) ;; déplace sur un nouveau tab
(map-normal :wr :<C-w>l) (map-normal "wÉ" :<C-w>T))
(map-normal :wC :<C-w>H)
(map-normal :wT :<C-w>J)
(map-normal :wS :<C-w>K)
(map-normal :wR :<C-w>L)
;; crée un split _h_orizontal
(map-normal :wh :<C-w>s)
;; va en haut à gauche
(map-normal "wé" :<C-w>t)
;; déplace sur un nouveau tab
(map-normal "wÉ" :<C-w>T))
(fn setup [] (fn setup []
"In any case, the following keys are always free for you to remap as you see fit: "In any case, the following keys are always free for you to remap as you see fit:

237
lua/bepo.lua generated
View File

@ -1,79 +1,178 @@
local function map_text_object(key, target)
vim.api.nvim_set_keymap("o", key, target, {noremap = true})
vim.api.nvim_set_keymap("x", key, target, {noremap = true})
return nil
end
local function map_visual(key, target)
vim.api.nvim_set_keymap("x", key, target, {noremap = true})
return nil
end
local function map_normal(key, target)
vim.api.nvim_set_keymap("n", key, target, {noremap = true})
return nil
end
local function map_all(key, target)
map_normal(key, target)
return map_text_object(key, target)
end
local function mapping_movement() local function mapping_movement()
map_all("c", "h") do
map_all("t", "j") vim.api.nvim_set_keymap("n", "c", "h", {noremap = true})
map_all("s", "k") vim.api.nvim_set_keymap("o", "c", "h", {noremap = true})
map_all("r", "l") vim.api.nvim_set_keymap("x", "c", "h", {noremap = true})
map_all("C", "H") end
map_all("T", "J") do
map_all("S", "K") vim.api.nvim_set_keymap("n", "t", "j", {noremap = true})
map_all("R", "L") vim.api.nvim_set_keymap("o", "t", "j", {noremap = true})
map_all("gt", "gj") vim.api.nvim_set_keymap("x", "t", "j", {noremap = true})
map_all("gs", "gk") end
map_all("zT", "zt") do
map_all("zt", "zj") vim.api.nvim_set_keymap("n", "s", "k", {noremap = true})
map_all("zk", "zs") vim.api.nvim_set_keymap("o", "s", "k", {noremap = true})
map_all("zs", "zk") vim.api.nvim_set_keymap("x", "s", "k", {noremap = true})
map_all("h", "t") end
map_all("H", "T") do
map_all("l", "c") vim.api.nvim_set_keymap("n", "r", "l", {noremap = true})
map_all("L", "C") vim.api.nvim_set_keymap("o", "r", "l", {noremap = true})
map_all("j", "r") vim.api.nvim_set_keymap("x", "r", "l", {noremap = true})
map_all("J", "R") end
map_all("k", "s") do
return map_all("K", "S") vim.api.nvim_set_keymap("n", "C", "H", {noremap = true})
vim.api.nvim_set_keymap("o", "C", "H", {noremap = true})
vim.api.nvim_set_keymap("x", "C", "H", {noremap = true})
end
do
vim.api.nvim_set_keymap("n", "T", "J", {noremap = true})
vim.api.nvim_set_keymap("o", "T", "J", {noremap = true})
vim.api.nvim_set_keymap("x", "T", "J", {noremap = true})
end
do
vim.api.nvim_set_keymap("n", "S", "K", {noremap = true})
vim.api.nvim_set_keymap("o", "S", "K", {noremap = true})
vim.api.nvim_set_keymap("x", "S", "K", {noremap = true})
end
do
vim.api.nvim_set_keymap("n", "R", "L", {noremap = true})
vim.api.nvim_set_keymap("o", "R", "L", {noremap = true})
vim.api.nvim_set_keymap("x", "R", "L", {noremap = true})
end
do
vim.api.nvim_set_keymap("n", "gt", "gj", {noremap = true})
vim.api.nvim_set_keymap("o", "gt", "gj", {noremap = true})
vim.api.nvim_set_keymap("x", "gt", "gj", {noremap = true})
end
do
vim.api.nvim_set_keymap("n", "gs", "gk", {noremap = true})
vim.api.nvim_set_keymap("o", "gs", "gk", {noremap = true})
vim.api.nvim_set_keymap("x", "gs", "gk", {noremap = true})
end
do
vim.api.nvim_set_keymap("n", "zT", "zt", {noremap = true})
vim.api.nvim_set_keymap("o", "zT", "zt", {noremap = true})
vim.api.nvim_set_keymap("x", "zT", "zt", {noremap = true})
end
do
vim.api.nvim_set_keymap("n", "zt", "zj", {noremap = true})
vim.api.nvim_set_keymap("o", "zt", "zj", {noremap = true})
vim.api.nvim_set_keymap("x", "zt", "zj", {noremap = true})
end
do
vim.api.nvim_set_keymap("n", "zk", "zs", {noremap = true})
vim.api.nvim_set_keymap("o", "zk", "zs", {noremap = true})
vim.api.nvim_set_keymap("x", "zk", "zs", {noremap = true})
end
do
vim.api.nvim_set_keymap("n", "zs", "zk", {noremap = true})
vim.api.nvim_set_keymap("o", "zs", "zk", {noremap = true})
vim.api.nvim_set_keymap("x", "zs", "zk", {noremap = true})
end
do
vim.api.nvim_set_keymap("n", "h", "t", {noremap = true})
vim.api.nvim_set_keymap("o", "h", "t", {noremap = true})
vim.api.nvim_set_keymap("x", "h", "t", {noremap = true})
end
do
vim.api.nvim_set_keymap("n", "H", "T", {noremap = true})
vim.api.nvim_set_keymap("o", "H", "T", {noremap = true})
vim.api.nvim_set_keymap("x", "H", "T", {noremap = true})
end
do
vim.api.nvim_set_keymap("n", "l", "c", {noremap = true})
vim.api.nvim_set_keymap("o", "l", "c", {noremap = true})
vim.api.nvim_set_keymap("x", "l", "c", {noremap = true})
end
do
vim.api.nvim_set_keymap("n", "L", "C", {noremap = true})
vim.api.nvim_set_keymap("o", "L", "C", {noremap = true})
vim.api.nvim_set_keymap("x", "L", "C", {noremap = true})
end
do
vim.api.nvim_set_keymap("n", "j", "r", {noremap = true})
vim.api.nvim_set_keymap("o", "j", "r", {noremap = true})
vim.api.nvim_set_keymap("x", "j", "r", {noremap = true})
end
do
vim.api.nvim_set_keymap("n", "J", "R", {noremap = true})
vim.api.nvim_set_keymap("o", "J", "R", {noremap = true})
vim.api.nvim_set_keymap("x", "J", "R", {noremap = true})
end
do
vim.api.nvim_set_keymap("n", "k", "s", {noremap = true})
vim.api.nvim_set_keymap("o", "k", "s", {noremap = true})
vim.api.nvim_set_keymap("x", "k", "s", {noremap = true})
end
vim.api.nvim_set_keymap("n", "K", "S", {noremap = true})
do
vim.api.nvim_set_keymap("o", "K", "S", {noremap = true})
vim.api.nvim_set_keymap("x", "K", "S", {noremap = true})
end
return nil
end end
local function mapping_tabs() local function mapping_tabs()
map_normal("gb", "gT") vim.api.nvim_set_keymap("n", "gb", "gT", {noremap = true})
map_normal("g\195\169", "gt") -- \195\169 = gé vim.api.nvim_set_keymap("n", "g\195\169", "gt", {noremap = true})
map_normal("gB", ":execute \"silent! tabfirst\"<CR>") vim.api.nvim_set_keymap("n", "gB", ":execute \"silent! tabfirst\"<CR>", {noremap = true})
map_normal("g\195\137", ":execute \"silent! tablast\"<CR>") -- \195\137 = gÉ vim.api.nvim_set_keymap("n", "g\195\137", ":execute \"silent! tablast\"<CR>", {noremap = true})
return map_normal("gT", "<C-]>") return vim.api.nvim_set_keymap("n", "gT", "<C-]>", {noremap = true})
end end
local function mapping_easy_access() local function mapping_easy_access()
map_normal("\194\171", "<") -- \194\171 = « vim.api.nvim_set_keymap("n", "\194\171", "<", {noremap = true})
map_visual("\194\171", "<gv") -- \194\171 = « vim.api.nvim_set_keymap("v", "\194\171", "<gv", {noremap = true})
map_normal("\194\187", ">") -- \194\187 = » vim.api.nvim_set_keymap("n", "\194\187", ">", {noremap = true})
map_visual("\194\187", ">gv") -- \194\187 = » vim.api.nvim_set_keymap("v", "\194\187", ">gv", {noremap = true})
map_all("g,", "g;") do
map_all("g;", "g,") vim.api.nvim_set_keymap("n", "g,", "g;", {noremap = true})
map_all("\195\169", "w") -- \195\169 = é vim.api.nvim_set_keymap("o", "g,", "g;", {noremap = true})
map_all("\195\137", "W") -- \195\137 = É vim.api.nvim_set_keymap("x", "g,", "g;", {noremap = true})
map_text_object("a\195\169", "aw") -- \195\169 = é end
map_text_object("a\195\137", "aW") -- \195\137 = É do
map_text_object("i\195\169", "iw") -- \195\169 = é vim.api.nvim_set_keymap("n", "g;", "g,", {noremap = true})
return map_text_object("i\195\137", "iW") -- \195\137 = É vim.api.nvim_set_keymap("o", "g;", "g,", {noremap = true})
vim.api.nvim_set_keymap("x", "g;", "g,", {noremap = true})
end
do
vim.api.nvim_set_keymap("n", "\195\169", "w", {noremap = true})
vim.api.nvim_set_keymap("o", "\195\169", "w", {noremap = true})
vim.api.nvim_set_keymap("x", "\195\169", "w", {noremap = true})
end
do
vim.api.nvim_set_keymap("n", "\195\137", "W", {noremap = true})
vim.api.nvim_set_keymap("o", "\195\137", "W", {noremap = true})
vim.api.nvim_set_keymap("x", "\195\137", "W", {noremap = true})
end
do
vim.api.nvim_set_keymap("o", "a\195\169", "aw", {noremap = true})
vim.api.nvim_set_keymap("x", "a\195\169", "aw", {noremap = true})
end
do
vim.api.nvim_set_keymap("o", "a\195\137", "aW", {noremap = true})
vim.api.nvim_set_keymap("x", "a\195\137", "aW", {noremap = true})
end
do
vim.api.nvim_set_keymap("o", "i\195\169", "iw", {noremap = true})
vim.api.nvim_set_keymap("x", "i\195\169", "iw", {noremap = true})
end
vim.api.nvim_set_keymap("o", "i\195\137", "iW", {noremap = true})
vim.api.nvim_set_keymap("x", "i\195\137", "iW", {noremap = true})
return nil
end end
local function mapping_window() local function mapping_window()
map_normal("w", "<C-w>") vim.api.nvim_set_keymap("n", "w", "<C-w>", {noremap = true})
map_normal("W", "<C-w><C-w>") vim.api.nvim_set_keymap("n", "W", "<C-w><C-w>", {noremap = true})
map_normal("wc", "<C-w>h") vim.api.nvim_set_keymap("n", "wc", "<C-w>h", {noremap = true})
map_normal("wt", "<C-w>j") vim.api.nvim_set_keymap("n", "wt", "<C-w>j", {noremap = true})
map_normal("ws", "<C-w>k") vim.api.nvim_set_keymap("n", "ws", "<C-w>k", {noremap = true})
map_normal("wr", "<C-w>l") vim.api.nvim_set_keymap("n", "wr", "<C-w>l", {noremap = true})
map_normal("wC", "<C-w>H") vim.api.nvim_set_keymap("n", "wC", "<C-w>H", {noremap = true})
map_normal("wT", "<C-w>J") vim.api.nvim_set_keymap("n", "wT", "<C-w>J", {noremap = true})
map_normal("wS", "<C-w>K") vim.api.nvim_set_keymap("n", "wS", "<C-w>K", {noremap = true})
map_normal("wR", "<C-w>L") vim.api.nvim_set_keymap("n", "wR", "<C-w>L", {noremap = true})
map_normal("wh", "<C-w>s") vim.api.nvim_set_keymap("n", "wh", "<C-w>s", {noremap = true})
map_normal("w\195\169", "<C-w>t") vim.api.nvim_set_keymap("n", "w\195\169", "<C-w>t", {noremap = true})
return map_normal("w\195\137", "<C-w>T") return vim.api.nvim_set_keymap("n", "w\195\137", "<C-w>T", {noremap = true})
end end
local function setup() local function setup()
if (vim.g.loaded_bepo_nvim == nil) then if (vim.g.loaded_bepo_nvim == nil) then

View File

@ -37,12 +37,11 @@
(local mapping-struct-header {:bepo :Bepo :modes :Modes :qwerty :Qwerty}) (local mapping-struct-header {:bepo :Bepo :modes :Modes :qwerty :Qwerty})
(fn print-mapping-struct [struct] (fn print-mapping-struct [struct]
(case struct (match struct
{: bepo : modes : qwerty} {: bepo : modes : qwerty}
(let [qw (if (= ">" qwerty) "> " qwerty)] (let [qw (if (= ">" qwerty) "> " qwerty)]
(print (.. (right-align modes 6) " " (left-align bepo 4) " " qw))) (print (.. (right-align modes 6) " " (left-align bepo 4) " " qw)))
_ _ (error (.. "Received an invalid struct" (fennel.view struct)))))
(error (.. "Received an invalid struct" (fennel.view struct)))))
(fn print-lua-import [name] (fn print-lua-import [name]
(->> (values (left-align (string.format "require(\"bepo\").%s()" name) 46) (->> (values (left-align (string.format "require(\"bepo\").%s()" name) 46)
@ -103,16 +102,12 @@ in each group. “Modes” have the same meaning as in the |map-table|.
(let [tbl (collect [name docstruct (pairs bepo)] (let [tbl (collect [name docstruct (pairs bepo)]
(if (= name :setup) nil (if (= name :setup) nil
(= (type docstruct) :table) (values name docstruct) (= (type docstruct) :table) (values name docstruct)
(error (.. "Invalid type for " name)))) (error (.. "Invalid type for " name))))]
tbl_keys (icollect [name docstructy (pairs tbl)]
name)]
(do (do
(table.sort tbl_keys) (table.sort tbl)
(each [_ name (pairs tbl_keys)] (each [name docstruct (pairs tbl)]
(do (do
(local docstruct (. tbl name))
(var need-header true) (var need-header true)
(fn print-header [] (fn print-header []
(do (do
(print-mapping-struct mapping-struct-header) (print-mapping-struct mapping-struct-header)
@ -126,13 +121,11 @@ in each group. “Modes” have the same meaning as in the |map-table|.
(print-header)) (print-header))
(each [i mapping-struct (pairs docstruct.body)] (each [i mapping-struct (pairs docstruct.body)]
(if need-header (print-hedear)) (if need-header (print-hedear))
(case mapping-struct (match mapping-struct
{:comment c} {:comment c} (do
(do (print (.. "\n" c))
(print (.. "\n" c)) (set need-header true))
(set need-header true)) _ (print-mapping-struct mapping-struct)))
_
(print-mapping-struct mapping-struct)))
(print ""))))) (print "")))))
;; We split the vim and the : to prevent vim from picking up that for the fennel file ;; We split the vim and the : to prevent vim from picking up that for the fennel file

View File

@ -1,5 +0,0 @@
-- The assumption is that this file will be used as configuration file with nvim
-- running from the root of the repository
vim.opt.runtimepath:append(vim.fn.getcwd())
require("bepo").setup()