Skip to content

Commit

Permalink
add more doc about endwise
Browse files Browse the repository at this point in the history
  • Loading branch information
windwp committed Jun 5, 2021
1 parent de99a68 commit 93f8b9f
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 6 deletions.
11 changes: 9 additions & 2 deletions doc/endwise.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#Endwise (experiment)
# Endwise (experiment)

** warning** use endwise base on treesitter is not always correct.
treesitter group all error node with parent node so we can't find
Expand All @@ -12,7 +12,7 @@ read docs in readme.md about rules first.
and install TSPlayground

``` lua
local npairs=require('nvim-autopairs')
local npairs = require('nvim-autopairs')
npairs.setup()

-- clear all rule if you don't want to use autopairs
Expand Down Expand Up @@ -45,3 +45,10 @@ take a look of that file and write your function

* `lua/nvim-autopairs/ts-rule.lua`
* `lua/nvim-autopairs/ts-conds.lua`

```lua
-- if you don't want to use regex or treesitter and want expand key on enter
-- you can use this rule
Rule('{', '}')
:end_wise(function() return true end),
```
2 changes: 1 addition & 1 deletion doc/rules.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
| use_regex(bool,"<key>") | input pair use regex and trigger by key |
| use_key('<key>') | change trigger key |
| replace_endpair(function) | change a map pair with function |
| end_wise(cond) | use it on end_wise mode |
| end_wise(cond) | expand pair only on enter key |

### Condition
```lua
Expand Down
5 changes: 2 additions & 3 deletions lua/nvim-autopairs.lua
Original file line number Diff line number Diff line change
Expand Up @@ -374,11 +374,10 @@ M.autopairs_cr = function(bufnr)
line = line
})
then
log.debug('do endwise')
return utils.esc(
rule.end_pair
.. utils.repeat_key(utils.key.left, #rule.end_pair)
.. "<cr><esc>O"
.. utils.repeat_key(utils.key.join_left, #rule.end_pair)
.. "<cr><esc>==O"
)
end
if
Expand Down

0 comments on commit 93f8b9f

Please sign in to comment.