diff --git a/doc/nvim-autopairs-rules.txt b/doc/nvim-autopairs-rules.txt index bc1a89fe..88e85a4b 100644 --- a/doc/nvim-autopairs-rules.txt +++ b/doc/nvim-autopairs-rules.txt @@ -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 @@ -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 `` while the cursor is between the pair (think -curly braces opening a block). Otherwise `` 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 `` while the cursor is between the pair +(think curly braces opening a block). Otherwise `` behaves as normal. For +example: > {|} @@ -199,8 +209,8 @@ Typing `` produces the following when `cond` is true: `WITH_DEL(COND)` ~ -If `cond` is true, when the cursor is between the pair, pressing `` 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 `` +to delete the opening part of the pair will delete the ending part as well. THE `USE_*` METHODS *nvim-autopairs-rules-the-`use_*`-methods* diff --git a/doc/nvim-autopairs.txt b/doc/nvim-autopairs.txt index ccc9bcdf..7e9e5df5 100644 --- a/doc/nvim-autopairs.txt +++ b/doc/nvim-autopairs.txt @@ -18,6 +18,19 @@ INSTALLATION *nvim-autopairs-installation* Install the plugin with your preferred package manager: +LAZY.NVIM ~ + +> + { + 'windwp/nvim-autopairs', + event = "InsertEnter", + config = true + -- use opts = {} for passing setup options + -- this is equivalent to setup({}) function + } +< + + VIM-PLUG ~ > @@ -34,7 +47,10 @@ PACKER ~ > use { "windwp/nvim-autopairs", - config = function() require("nvim-autopairs").setup {} end + event = "InsertEnter", + config = function() + require("nvim-autopairs").setup {} + end } < @@ -42,22 +58,24 @@ PACKER ~ 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 key - local map_c_h = false -- Map the key to delete a pair - local map_c_w = false -- map 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 key + map_c_h = false -- Map the key to delete a pair + map_c_w = false -- map to delete a pair if possible + } < @@ -135,7 +153,7 @@ Mapping `` You can customize the kind of completion ---@param rules table ---@param commit_character table 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 } }, @@ -371,10 +389,10 @@ PLUGIN INTEGRATION ~ > require('nvim-autopairs').disable() require('nvim-autopairs').enable() + require('nvim-autopairs').toggle() 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('"') < @@ -384,18 +402,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 then press $ (|foobar) + Before Input After Note + ----------------------------------------------------------------- + (|foobar then press $ (|foobar) (|)(foobar) then press q (|(foobar)) + (|foo bar then press qh (|foo) bar + (|foo bar then press qH (foo|) bar + (|foo bar then press qH (foo)| bar if cursor_pos_before = false < @@ -412,8 +433,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' }, @@ -436,8 +460,10 @@ rules SPONSORS *nvim-autopairs-sponsors* Thanks to everyone who sponsors my projects and makes continued development -maintenance possible! +maintenance possible! + +george looshch Generated by panvimdoc