Skip to content

Commit ed7ed67

Browse files
authored
Merge pull request #116 from monaqa/docs-organize_readme
docs: update & fix README
2 parents 03f8f32 + de4a41f commit ed7ed67

2 files changed

Lines changed: 52 additions & 62 deletions

File tree

README.md

Lines changed: 22 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,5 @@
11
# dial.nvim
22

3-
**NOTICE: This plugin is work-in-progress yet. User interface is subject to change without notice.**
4-
5-
## FOR USERS OF THE PREVIOUS VERSION (v0.2.0)
6-
7-
This plugin was released v0.3.0 on 2022/02/20 and is no longer compatible with the old interface.
8-
If you have configured the settings for previous versions, please refer to [TROUBLESHOOTING.md](./TROUBLESHOOTING.md) and reconfigure them.
9-
103
## Abstract
114

125
Extended increment/decrement plugin for [Neovim](https://github.com/neovim/neovim). Written in Lua.
@@ -17,6 +10,7 @@ Extended increment/decrement plugin for [Neovim](https://github.com/neovim/neovi
1710

1811
* Increment/decrement based on various type of rules
1912
* n-ary (`2 <= n <= 36`) integers
13+
* decimal Fractions
2014
* date and time
2115
* constants (an ordered set of specific strings, such as a keyword or operator)
2216
* `true``false`
@@ -73,16 +67,16 @@ end)
7367
vim.keymap.set("n", "g<C-x>", function()
7468
require("dial.map").manipulate("decrement", "gnormal")
7569
end)
76-
vim.keymap.set("v", "<C-a>", function()
70+
vim.keymap.set("x", "<C-a>", function()
7771
require("dial.map").manipulate("increment", "visual")
7872
end)
79-
vim.keymap.set("v", "<C-x>", function()
73+
vim.keymap.set("x", "<C-x>", function()
8074
require("dial.map").manipulate("decrement", "visual")
8175
end)
82-
vim.keymap.set("v", "g<C-a>", function()
76+
vim.keymap.set("x", "g<C-a>", function()
8377
require("dial.map").manipulate("increment", "gvisual")
8478
end)
85-
vim.keymap.set("v", "g<C-x>", function()
79+
vim.keymap.set("x", "g<C-x>", function()
8680
require("dial.map").manipulate("decrement", "gvisual")
8781
end)
8882
```
@@ -131,28 +125,22 @@ nmap <Leader>a "=mygroup<CR><Plug>(dial-increment)
131125
Alternatively, you can set the same mapping without expression register:
132126

133127
```lua
134-
vim.keymap.set("n", "<Leader>a", require("dial.map").inc_normal("mygroup"), {noremap = true})
128+
vim.keymap.set("n", "<Leader>a", require("dial.map").inc_normal("mygroup"))
135129
```
136130

137131
When you don't specify any group name in the way described above, the addends in the `default` group is used instead.
138132

139133
### Example Configuration
140134

141-
```vim
142-
lua << EOF
135+
```lua
143136
local augend = require("dial.augend")
144137
require("dial.config").augends:register_group{
145138
default = {
146139
augend.integer.alias.decimal,
147140
augend.integer.alias.hex,
148141
augend.date.alias["%Y/%m/%d"],
149142
},
150-
typescript = {
151-
augend.integer.alias.decimal,
152-
augend.integer.alias.hex,
153-
augend.constant.new{ elements = {"let", "const"} },
154-
},
155-
visual = {
143+
only_in_visual = {
156144
augend.integer.alias.decimal,
157145
augend.integer.alias.hex,
158146
augend.date.alias["%Y/%m/%d"],
@@ -161,14 +149,21 @@ require("dial.config").augends:register_group{
161149
},
162150
}
163151

164-
-- change augends in VISUAL mode
165-
vim.keymap.set("v", "<C-a>", require("dial.map").inc_visual("visual"), {noremap = true})
166-
vim.keymap.set("v", "<C-x>", require("dial.map").dec_visual("visual"), {noremap = true})
167-
EOF
152+
-- Use `only_in_visual` group only in VISUAL <C-a> / <C-x>
153+
vim.keymap.set("x", "<C-a>", function()
154+
require("dial.map").manipulate("increment", "visual", "only_in_visual")
155+
end)
156+
vim.keymap.set("x", "<C-x>", function()
157+
require("dial.map").manipulate("decrement", "visual", "only_in_visual")
158+
end)
168159

169-
" enable only for specific FileType
170-
autocmd FileType typescript lua vim.api.nvim_buf_set_keymap(0, "n", "<C-a>", require("dial.map").inc_normal("typescript"), {noremap = true})
171-
autocmd FileType typescript lua vim.api.nvim_buf_set_keymap(0, "n", "<C-x>", require("dial.map").dec_normal("typescript"), {noremap = true})
160+
require("dial.config").augends:on_filetype {
161+
typescript = {
162+
augend.integer.alias.decimal,
163+
augend.integer.alias.hex,
164+
augend.constant.new{ elements = {"let", "const"} },
165+
},
166+
}
172167
```
173168

174169
## List of Augends

README_ja.md

Lines changed: 30 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,5 @@
11
# dial.nvim
22

3-
**NOTICE: 本プラグインはまだ開発段階であり、事前告知なくインターフェースが変更となることがあります。**
4-
5-
## 旧バージョン (v0.2.0) を使っていた人へ
6-
7-
2022/02/20 に v0.3.0 がリリースされ、既存のインターフェースとの互換性がなくなりました。
8-
以前のバージョン向けの設定を行っていた方は、[TROUBLESHOOTING.md](./TROUBLESHOOTING_ja.md) を参考に再設定を行ってください。
9-
103
## 概要
114

125
[Neovim](https://github.com/neovim/neovim) の数値増減機能を拡張する Lua 製プラグイン。
@@ -18,6 +11,7 @@
1811

1912
* 数値をはじめとする様々なものの増減
2013
* n 進数 (`2 <= n <= 36`) の整数
14+
* 小数
2115
* 日付・時刻
2216
* キーワードや演算子など、所定文字列のトグル
2317
* `true``false`
@@ -50,14 +44,14 @@
5044
本プラグインを有効にするには、いずれかのキーに以下のような割り当てを行う必要があります。
5145

5246
```vim
53-
nmap <C-a> <Plug>(dial-increment)
54-
nmap <C-x> <Plug>(dial-decrement)
55-
nmap g<C-a> g<Plug>(dial-increment)
56-
nmap g<C-x> g<Plug>(dial-decrement)
57-
vmap <C-a> <Plug>(dial-increment)
58-
vmap <C-x> <Plug>(dial-decrement)
59-
vmap g<C-a> g<Plug>(dial-increment)
60-
vmap g<C-x> g<Plug>(dial-decrement)
47+
nnoremap <C-a> <Plug>(dial-increment)
48+
nnoremap <C-x> <Plug>(dial-decrement)
49+
nnoremap g<C-a> <Plug>(dial-g-increment)
50+
nnoremap g<C-x> <Plug>(dial-g-decrement)
51+
xnoremap <C-a> <Plug>(dial-increment)
52+
xnoremap <C-x> <Plug>(dial-decrement)
53+
xnoremap g<C-a> <Plug>(dial-g-increment)
54+
xnoremap g<C-x> <Plug>(dial-g-decrement)
6155
```
6256

6357
または Lua 上で以下のように設定することもできます。
@@ -75,16 +69,16 @@ end)
7569
vim.keymap.set("n", "g<C-x>", function()
7670
require("dial.map").manipulate("decrement", "gnormal")
7771
end)
78-
vim.keymap.set("v", "<C-a>", function()
72+
vim.keymap.set("x", "<C-a>", function()
7973
require("dial.map").manipulate("increment", "visual")
8074
end)
81-
vim.keymap.set("v", "<C-x>", function()
75+
vim.keymap.set("x", "<C-x>", function()
8276
require("dial.map").manipulate("decrement", "visual")
8377
end)
84-
vim.keymap.set("v", "g<C-a>", function()
78+
vim.keymap.set("x", "g<C-a>", function()
8579
require("dial.map").manipulate("increment", "gvisual")
8680
end)
87-
vim.keymap.set("v", "g<C-x>", function()
81+
vim.keymap.set("x", "g<C-x>", function()
8882
require("dial.map").manipulate("decrement", "gvisual")
8983
end)
9084
```
@@ -132,28 +126,22 @@ nmap <Leader>a "=mygroup<CR><Plug>(dial-increment)
132126
また、 Lua 上で以下のように記述すれば expression register を使わずにマッピングを設定できます。
133127

134128
```lua
135-
vim.keymap.set("n", "<Leader>a", require("dial.map").inc_normal("mygroup"), {noremap = true})
129+
vim.keymap.set("n", "<Leader>a", require("dial.map").inc_normal("mygroup"))
136130
```
137131

138132
expression register などでグループ名を指定しなかった場合、`default` グループにある被加数がかわりに用いられます。
139133

140134
### 設定例
141135

142-
```vim
143-
lua << EOF
136+
```lua
144137
local augend = require("dial.augend")
145138
require("dial.config").augends:register_group{
146139
default = {
147140
augend.integer.alias.decimal,
148141
augend.integer.alias.hex,
149142
augend.date.alias["%Y/%m/%d"],
150143
},
151-
typescript = {
152-
augend.integer.alias.decimal,
153-
augend.integer.alias.hex,
154-
augend.constant.new{ elements = {"let", "const"} },
155-
},
156-
visual = {
144+
only_in_visual = {
157145
augend.integer.alias.decimal,
158146
augend.integer.alias.hex,
159147
augend.date.alias["%Y/%m/%d"],
@@ -162,14 +150,21 @@ require("dial.config").augends:register_group{
162150
},
163151
}
164152

165-
-- VISUAL モードでの被加数を変更する
166-
vim.keymap.set("v", "<C-a>", require("dial.map").inc_visual("visual"), {noremap = true})
167-
vim.keymap.set("v", "<C-x>", require("dial.map").dec_visual("visual"), {noremap = true})
168-
EOF
153+
-- Use `only_in_visual` group only in VISUAL <C-a> / <C-x>
154+
vim.keymap.set("x", "<C-a>", function()
155+
require("dial.map").manipulate("increment", "visual", "only_in_visual")
156+
end)
157+
vim.keymap.set("x", "<C-x>", function()
158+
require("dial.map").manipulate("decrement", "visual", "only_in_visual")
159+
end)
169160

170-
" 特定のファイルタイプでのみ有効にする
171-
autocmd FileType typescript lua vim.api.nvim_buf_set_keymap(0, "n", "<C-a>", require("dial.map").inc_normal("typescript"), {noremap = true})
172-
autocmd FileType typescript lua vim.api.nvim_buf_set_keymap(0, "n", "<C-x>", require("dial.map").dec_normal("typescript"), {noremap = true})
161+
require("dial.config").augends:on_filetype {
162+
typescript = {
163+
augend.integer.alias.decimal,
164+
augend.integer.alias.hex,
165+
augend.constant.new{ elements = {"let", "const"} },
166+
},
167+
}
173168
```
174169

175170
## 被加数の種類と一覧

0 commit comments

Comments
 (0)