Skip to content

Commit

Permalink
Merge pull request #76 from monaqa/docs-note_remap
Browse files Browse the repository at this point in the history
update documents
  • Loading branch information
monaqa authored Sep 9, 2023
2 parents 5b9763e + 7f3f527 commit 611cf5e
Show file tree
Hide file tree
Showing 5 changed files with 92 additions and 38 deletions.
34 changes: 26 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -58,17 +58,35 @@ vmap g<C-a> g<Plug>(dial-increment)
vmap g<C-x> g<Plug>(dial-decrement)
```

Note: When you use "g<Plug>(dial-increment)" or "g<Plug>(dial-decrement)" on the right side, `remap` option must be enabled.

Or you can configure it with Lua as follows:

```lua
vim.keymap.set("n", "<C-a>", require("dial.map").inc_normal(), {noremap = true})
vim.keymap.set("n", "<C-x>", require("dial.map").dec_normal(), {noremap = true})
vim.keymap.set("n", "g<C-a>", require("dial.map").inc_gnormal(), {noremap = true})
vim.keymap.set("n", "g<C-x>", require("dial.map").dec_gnormal(), {noremap = true})
vim.keymap.set("v", "<C-a>", require("dial.map").inc_visual(), {noremap = true})
vim.keymap.set("v", "<C-x>", require("dial.map").dec_visual(), {noremap = true})
vim.keymap.set("v", "g<C-a>",require("dial.map").inc_gvisual(), {noremap = true})
vim.keymap.set("v", "g<C-x>",require("dial.map").dec_gvisual(), {noremap = true})
vim.keymap.set("n", "<C-a>", function()
require("dial.map").manipulate("increment", "normal")
end)
vim.keymap.set("n", "<C-x>", function()
require("dial.map").manipulate("decrement", "normal")
end)
vim.keymap.set("n", "g<C-a>", function()
require("dial.map").manipulate("increment", "gnormal")
end)
vim.keymap.set("n", "g<C-x>", function()
require("dial.map").manipulate("decrement", "gnormal")
end)
vim.keymap.set("v", "<C-a>", function()
require("dial.map").manipulate("increment", "visual")
end)
vim.keymap.set("v", "<C-x>", function()
require("dial.map").manipulate("decrement", "visual")
end)
vim.keymap.set("v", "g<C-a>", function()
require("dial.map").manipulate("increment", "gvisual")
end)
vim.keymap.set("v", "g<C-x>", function()
require("dial.map").manipulate("decrement", "gvisual")
end)
```

## Configuration
Expand Down
34 changes: 26 additions & 8 deletions README_ja.md
Original file line number Diff line number Diff line change
Expand Up @@ -61,17 +61,35 @@ vmap g<C-a> g<Plug>(dial-increment)
vmap g<C-x> g<Plug>(dial-decrement)
```

注意: `g<Plug>(dial-increment)``g<Plug>(dial-decrement)` を右辺で用いる場合は remap を有効にする必要があります。

または Lua 上で以下のように設定することもできます。

```lua
vim.keymap.set("n", "<C-a>", require("dial.map").inc_normal(), {noremap = true})
vim.keymap.set("n", "<C-x>", require("dial.map").dec_normal(), {noremap = true})
vim.keymap.set("n", "g<C-a>", require("dial.map").inc_gnormal(), {noremap = true})
vim.keymap.set("n", "g<C-x>", require("dial.map").dec_gnormal(), {noremap = true})
vim.keymap.set("v", "<C-a>", require("dial.map").inc_visual(), {noremap = true})
vim.keymap.set("v", "<C-x>", require("dial.map").dec_visual(), {noremap = true})
vim.keymap.set("v", "g<C-a>", require("dial.map").inc_gvisual(), {noremap = true})
vim.keymap.set("v", "g<C-x>", require("dial.map").dec_gvisual(), {noremap = true})
vim.keymap.set("n", "<C-a>", function()
require("dial.map").manipulate("increment", "normal")
end)
vim.keymap.set("n", "<C-x>", function()
require("dial.map").manipulate("decrement", "normal")
end)
vim.keymap.set("n", "g<C-a>", function()
require("dial.map").manipulate("increment", "gnormal")
end)
vim.keymap.set("n", "g<C-x>", function()
require("dial.map").manipulate("decrement", "gnormal")
end)
vim.keymap.set("v", "<C-a>", function()
require("dial.map").manipulate("increment", "visual")
end)
vim.keymap.set("v", "<C-x>", function()
require("dial.map").manipulate("decrement", "visual")
end)
vim.keymap.set("v", "g<C-a>", function()
require("dial.map").manipulate("increment", "gvisual")
end)
vim.keymap.set("v", "g<C-x>", function()
require("dial.map").manipulate("decrement", "gvisual")
end)
```

## 設定方法
Expand Down
23 changes: 16 additions & 7 deletions doc/dial.jax
Original file line number Diff line number Diff line change
Expand Up @@ -189,11 +189,12 @@ Lua 上で以下のように記述すれば expression register を使わずマ
きます。

>
vim.api.nvim_set_keymap(
vim.keymap.set(
"n",
"<Leader>a",
require("dial.map").inc_normal("mygroup"),
{noremap = true}
function()
require("dial.map").manipulate("increment", "normal", "mygroup")
end
)
<

Expand Down Expand Up @@ -255,11 +256,19 @@ VISUAL モード用のグループを作成することで可能です。
}
-- VISUAL モードでの被加数を変更する
vim.api.nvim_set_keymap(
"v", "<C-a>", require("dial.map").inc_normal("visual"), {noremap = true}
vim.keymap.set(
"v",
"<C-a>",
function()
require("dial.map").manipulate("increment", "visual", "visual")
end
)
vim.api.nvim_set_keymap(
"v", "<C-x>", require("dial.map").dec_normal("visual"), {noremap = true}
vim.keymap.set(
"v",
"<C-x>",
function()
require("dial.map").manipulate("decrement", "visual", "visual")
end
)
<

Expand Down
23 changes: 16 additions & 7 deletions doc/dial.txt
Original file line number Diff line number Diff line change
Expand Up @@ -189,11 +189,12 @@ decrease, you can "map" it:

Alternatively, you can set the same mapping without expression register:
>
vim.api.nvim_set_keymap(
vim.keymap.set(
"n",
"<Leader>a",
require("dial.map").inc_normal("mygroup"),
{noremap = true}
function()
require("dial.map").manipulate("increment", "normal", "mygroup")
end
)
<

Expand Down Expand Up @@ -253,11 +254,19 @@ Augends Only Valid in VISUAL Mode~
}
-- change augends in VISUAL mode
vim.api.nvim_set_keymap(
"v", "<C-a>", require("dial.map").inc_normal("visual"), {noremap = true}
vim.keymap.set(
"v",
"<C-a>",
function()
require("dial.map").manipulate("increment", "visual", "visual")
end
)
vim.api.nvim_set_keymap(
"v", "<C-x>", require("dial.map").dec_normal("visual"), {noremap = true}
vim.keymap.set(
"v",
"<C-x>",
function()
require("dial.map").manipulate("decrement", "visual", "visual")
end
)
<

Expand Down
16 changes: 8 additions & 8 deletions plugin/dial.vim
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,14 @@ let s:save_cpo = &cpo " save user coptions
set cpo&vim " reset them to defaults

lua << EOF
vim.api.nvim_set_keymap("n", "<Plug>(dial-increment)", require("dial.map").inc_normal(), {noremap = true})
vim.api.nvim_set_keymap("n", "<Plug>(dial-decrement)", require("dial.map").dec_normal(), {noremap = true})
vim.api.nvim_set_keymap("n", "g<Plug>(dial-increment)", require("dial.map").inc_gnormal(), {noremap = true})
vim.api.nvim_set_keymap("n", "g<Plug>(dial-decrement)", require("dial.map").dec_gnormal(), {noremap = true})
vim.api.nvim_set_keymap("v", "<Plug>(dial-increment)", require("dial.map").inc_visual() .. "gv", {noremap = true})
vim.api.nvim_set_keymap("v", "<Plug>(dial-decrement)", require("dial.map").dec_visual() .. "gv", {noremap = true})
vim.api.nvim_set_keymap("v", "g<Plug>(dial-increment)", require("dial.map").inc_gvisual() .. "gv", {noremap = true})
vim.api.nvim_set_keymap("v", "g<Plug>(dial-decrement)", require("dial.map").dec_gvisual() .. "gv", {noremap = true})
vim.keymap.set("n", "<Plug>(dial-increment)", require("dial.map").inc_normal())
vim.keymap.set("n", "<Plug>(dial-decrement)", require("dial.map").dec_normal())
vim.keymap.set("n", "g<Plug>(dial-increment)", require("dial.map").inc_gnormal())
vim.keymap.set("n", "g<Plug>(dial-decrement)", require("dial.map").dec_gnormal())
vim.keymap.set("v", "<Plug>(dial-increment)", require("dial.map").inc_visual() .. "gv")
vim.keymap.set("v", "<Plug>(dial-decrement)", require("dial.map").dec_visual() .. "gv")
vim.keymap.set("v", "g<Plug>(dial-increment)", require("dial.map").inc_gvisual() .. "gv")
vim.keymap.set("v", "g<Plug>(dial-decrement)", require("dial.map").dec_gvisual() .. "gv")
EOF

command! -range -nargs=? DialIncrement lua require"dial.command".command("increment", {from = <line1>, to = <line2>}, {<f-args>})
Expand Down

0 comments on commit 611cf5e

Please sign in to comment.