Skip to content

Commit

Permalink
chore: generated vimdoc
Browse files Browse the repository at this point in the history
  • Loading branch information
github-actions[bot] committed Feb 25, 2024
1 parent c6139ca commit 36fd4ed
Show file tree
Hide file tree
Showing 2 changed files with 73 additions and 40 deletions.
38 changes: 24 additions & 14 deletions doc/nvim-autopairs-rules.txt
Expand Up @@ -156,6 +156,15 @@ takes place. There are no predicates if you don’t define any, and so any
events without predicates behave as if they had a single predicate that always
returns true.

The predicate functions will receive an `opts` table with the following fields:
- `rule` the `Rule` object - `bufnr` the buffer number - `col` the current
column (1-indexed) - `ts_node` the current treesitter node (if treesitter is
enabled) - `text` the current line, with typed char inserted - `line` the
current line, before substitutions - `char` the typed char - `prev_char` the
text just before cursor (with length `== #rule.start_pair`) - `next_char` the
text just after cursor (with length `== #rule.start_pair` if rule is not regex,
else end of line)

A `Rule` may have more than one predicate defined for a given event, and the
order that they are defined will be the order that they are checked. However,
the **first** non-`nil` value returned by a predicate is used and the remaining
Expand All @@ -164,24 +173,25 @@ earlier have priority over predicates defined later.

`WITH_PAIR(COND, POS)` ~

After typing the opening part, `cond` will fire and the ending part will only
be added if `cond` returned true. `with_pair` may be called more than once, and
by default, each predicate is appended to a list. When the "pair" event fires,
the _first_ predicate to return non-nil is used as the condition result.
Specifying `pos` allows explicit control over the order of the predicates.
After typing the opening part, the ending part will only be added if
`cond(opts)` returned true. `with_pair` may be called more than once, and by
default, each predicate is appended to a list. When the "pair" event fires, the
_first_ predicate to return non-nil is used as the condition result. Specifying
`pos` allows explicit control over the order of the predicates.

`WITH_MOVE(COND)` ~

If `cond` is true, the cursor is simply moved right when typing the ending part
of the pair and the next character is also the ending part, e.g. `|" -> "|`
when typing `"`. If `cond` returns false, the ending part is inserted as normal
instead.
If `cond(opts)` is true, the cursor is simply moved right when typing the
ending part of the pair and the next character is also the ending part,
e.g. `foo|"` => `foo"|` when typing `"`. If `cond(opts)` returns false, the
ending part is inserted as normal instead.

`WITH_CR(COND)` ~

If `cond` is true, then move the ending part of the pair to a new line below
the cursor after pressing `<CR>` while the cursor is between the pair (think
curly braces opening a block). Otherwise `<CR>` behaves as normal. For example:
If `cond(opts)` is true, then move the ending part of the pair to a new line
below the cursor after pressing `<CR>` while the cursor is between the pair
(think curly braces opening a block). Otherwise `<CR>` behaves as normal. For
example:

>
{|}
Expand All @@ -199,8 +209,8 @@ Typing `<CR>` produces the following when `cond` is true:

`WITH_DEL(COND)` ~

If `cond` is true, when the cursor is between the pair, pressing `<BS>` to
delete the opening part of the pair will delete the ending part as well.
If `cond(opts)` is true, when the cursor is between the pair, pressing `<BS>`
to delete the opening part of the pair will delete the ending part as well.

THE `USE_*` METHODS *nvim-autopairs-rules-the-`use_*`-methods*

Expand Down
75 changes: 49 additions & 26 deletions doc/nvim-autopairs.txt
Expand Up @@ -18,6 +18,19 @@ INSTALLATION *nvim-autopairs-installation*

Install the plugin with your preferred package manager:

LAZY.NVIM <HTTPS://GITHUB.COM/FOLKE/LAZY.NVIM> ~

>
{
'windwp/nvim-autopairs',
event = "InsertEnter",
config = true
-- use opts = {} for passing setup options
-- this is equalent to setup({}) function
}
<


VIM-PLUG <HTTPS://GITHUB.COM/JUNEGUNN/VIM-PLUG> ~

>
Expand All @@ -34,30 +47,35 @@ PACKER <HTTPS://GITHUB.COM/WBTHOMASON/PACKER.NVIM> ~
>
use {
"windwp/nvim-autopairs",
config = function() require("nvim-autopairs").setup {} end
event = "InsertEnter",
config = function()
require("nvim-autopairs").setup {}
end
}
<


DEFAULT VALUES *nvim-autopairs-default-values*

>
local disable_filetype = { "TelescopePrompt" }
local disable_in_macro = false -- disable when recording or executing a macro
local disable_in_visualblock = false -- disable when insert after visual block mode
local disable_in_replace_mode = true
local ignored_next_char = [=[[%w%%%'%[%"%.%`%$]]=]
local enable_moveright = true
local enable_afterquote = true -- add bracket pairs after quote
local enable_check_bracket_line = true --- check bracket in same line
local enable_bracket_in_quote = true --
local enable_abbr = false -- trigger abbreviation
local break_undo = true -- switch for basic rule break undo sequence
local check_ts = false
local map_cr = true
local map_bs = true -- map the <BS> key
local map_c_h = false -- Map the <C-h> key to delete a pair
local map_c_w = false -- map <c-w> to delete a pair if possible
{
disable_filetype = { "TelescopePrompt", "spectre_panel" }
disable_in_macro = true -- disable when recording or executing a macro
disable_in_visualblock = false -- disable when insert after visual block mode
disable_in_replace_mode = true
ignored_next_char = [=[[%w%%%'%[%"%.%`%$]]=]
enable_moveright = true
enable_afterquote = true -- add bracket pairs after quote
enable_check_bracket_line = true --- check bracket in same line
enable_bracket_in_quote = true --
enable_abbr = false -- trigger abbreviation
break_undo = true -- switch for basic rule break undo sequence
check_ts = false
map_cr = true
map_bs = true -- map the <BS> key
map_c_h = false -- Map the <C-h> key to delete a pair
map_c_w = false -- map <c-w> to delete a pair if possible
}
<


Expand Down Expand Up @@ -135,7 +153,7 @@ Mapping `<CR>` You can customize the kind of completion
---@param rules table
---@param commit_character table<string>
handler = function(char, item, bufnr, rules, commit_character)
-- Your handler function. Inpect with print(vim.inspect{char, item, bufnr, rules, commit_character})
-- Your handler function. Inspect with print(vim.inspect{char, item, bufnr, rules, commit_character})
end
}
},
Expand Down Expand Up @@ -373,8 +391,7 @@ PLUGIN INTEGRATION ~
require('nvim-autopairs').enable()
require('nvim-autopairs').remove_rule('(') -- remove rule (
require('nvim-autopairs').clear_rules() -- clear all rules
-- get rule " then modify it. It can return a list of rule or just a rule
require('nvim-autopairs').get_rule('"')
require('nvim-autopairs').get_rules('"')
<


Expand All @@ -384,18 +401,21 @@ PLUGIN INTEGRATION ~

>
-- remove add single quote on filetype scheme or lisp
require("nvim-autopairs").get_rule("'")[1].not_filetypes = { "scheme", "lisp" }
require("nvim-autopairs").get_rule("'")[1]:with_pair(cond.not_after_text("["}))
require("nvim-autopairs").get_rules("'")[1].not_filetypes = { "scheme", "lisp" }
require("nvim-autopairs").get_rules("'")[1]:with_pair(cond.not_after_text("["))
<


FASTWRAP ~

>
Before Input After
--------------------------------------------------
(|foobar <M-e> then press $ (|foobar)
Before Input After Note
-----------------------------------------------------------------
(|foobar <M-e> then press $ (|foobar)
(|)(foobar) <M-e> then press q (|(foobar))
(|foo bar <M-e> then press qh (|foo) bar
(|foo bar <M-e> then press qH (foo|) bar
(|foo bar <M-e> then press qH (foo)| bar if cursor_pos_before = false
<


Expand All @@ -412,8 +432,11 @@ FASTWRAP ~
chars = { '{', '[', '(', '"', "'" },
pattern = [=[[%'%"%>%]%)%}%,]]=],
end_key = '$',
before_key = 'h',
after_key = 'l',
cursor_pos_before = true,
keys = 'qwertyuiopzxcvbnmasdfghjkl',
check_comma = true,
manual_position = true,
highlight = 'Search',
highlight_grey='Comment'
},
Expand Down

0 comments on commit 36fd4ed

Please sign in to comment.