nvim-autopairs/doc/nvim-autopairs-rules.txt
2021-12-19 05:36:47 +07:00

101 lines
4.3 KiB
Plaintext

*nvim-autopairs-rules.txt* nvim-autopairs rules
==============================================================================
Table of Contents *nvim-autopairs-rules-table-of-contents*
- Define rule with a pairs |nvim-autopairs-rules-define-rule-with-a-pairs|
- Rules |nvim-autopairs-rules-rules|
DEFINE RULE WITH A PAIRS *nvim-autopairs-rules-define-rule-with-a-pairs*
Rule(begin_pair, end_pair, filetypes)
- You can use string or a table(array) on file type
`Rule("(",")", "markdown")` ,`Rule("(",")", {"markdown","vim"})`
- If you add minus "-" before file type mean that rule is not working on that file type.
`Rule("a","a","-vim")`
RULES *nvim-autopairs-rules-rules*
│ function │ usage │
│with_pair(cond) │add condition to check for pair event │
│with_move(cond) │add condition to check for move right event │
│with_cr(cond) │add condition to check for break line event │
│with_del(cond) │add condition to check for delete pair event │
│only_cr(cond) │disable move,del and pair event Only use break li│
│ │ne event │
│use_regex(bool,"<key>")│input pair use regex and trigger by key │
│ │ │
│use_key('<key>') │change trigger key │
│replace_endpair(func) │change a map pair with function │
│set_end_pair_length(num│help to move a cursor to a middle of the end pair│
│ber) │ │
│ │when you use a replace_endpair with key <left> <P│
│ │lug> │
│replace_map_cr(func) │change a map on cr key with with function │
│end_wise(cond) │expand pair only on enter key │
*nvim-autopairs-rules-replace_endpair*
replace_endpair paramaters 2 of replace_endpair use to
combine with with_pair function
>
Rule("(",")")
:use_key("<c-h>")
:replace_endpair(function() return "<bs><del>" end, true)
-- it is a short version of this
Rule("(","")
:use_key("<c-h>")
:with_pair(cond.after_text(")")) -- check text after cursor is )
:replace_endpair(function() return "<bs><del>" end)
<
CONDITION ~
>
local cond = require('nvim-autopairs.conds')
<
│ function │ Usage │
│none() │always wrong │
│done() │always correct │
│before_text(text) │check character before │
│after_text(text) │check character after │
│before_regex(regex,length) │check character before with lua regex│
│after_regex(regex,length) │check character after with lua regex │
│not_before_text(text) │check character before │
│not_after_text(text) │check character after │
│not_before_regex(regex,length)│check character before with lua regex│
│not_after_regex(regex,length) │check character after with lua regex │
│not_inside_quote() │check is not inside a quote │
│not_filetypes({table}) │check filetype is not inside table │
- cond.not_filetypes should be use by add minus on filetype when you declare rule.
Rule("a","a","-vim") because it is complete remove that rule on buffer.
TREESITTER CONDITION ~
>
local ts_conds = require('nvim-autopairs.ts-conds')
<
│ function │ Usage │
│is_ts_node({node_table}) │check current treesitter node│
│is_not_ts_node({node_table})│check not in treesitter node │
Generated by panvimdoc <https://github.com/kdheepak/panvimdoc>
vim:tw=78:ts=8:noet:ft=help:norl: