Skip to content

Commit 6f2c32e

Browse files
committed
Clean up bad <CR> fuckery wrt. autocomplete (#66)
1 parent 16894ff commit 6f2c32e

File tree

4 files changed

+14
-32
lines changed

4 files changed

+14
-32
lines changed

README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ To use experimental changes before they're deployed, use:
2626
Plug 'LunarWatcher/auto-pairs', {'branch': 'develop'}
2727
```
2828

29-
**Note:** As of 4.0.0, `let g:AutoPairsCompatibleMaps = 0` is default. Set the variable to 1 to use jiangmiao-compatible keybinds.
29+
**Note:** As of 4.0.0, `let g:AutoPairsCompatibleMaps = 0` is the default. Set the variable to 1 to use jiangmiao-compatible keybinds.
3030

3131
## Running tests (not required)
3232

@@ -72,6 +72,7 @@ Functionally, however, it's meant to resemble upstream as much as possible, part
7272
* ... and with new ones.
7373
* Increased customizability
7474

75+
7576
## Non-goals
7677
* Being a drop-in snippet replacement -- use UltiSnips or lexima.vim instead.
7778
* Supporting very old versions of Vim

doc/AutoPairs.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1179,7 +1179,7 @@ jiangmiao/auto-pairs.
11791179

11801180
DO NOT MODIFY
11811181
This variable is a constant per version, and exists for compatibility reasons.
1182-
Do not set this variable yourself. This canc and will have unintended
1182+
Do not set this variable yourself. This can and will have unintended
11831183
consequences.
11841184

11851185
Defines the current version. Note that while this is largely intended to
@@ -1738,7 +1738,7 @@ This function initialises all the global variables auto-pairs uses.
17381738

17391739
While primarily intended for internal use, it can be used to force load
17401740
auto-pairs' variables. This is more or less entirely intended for object or
1741-
list variables, where setting the value may override other desired variabels,
1741+
list variables, where setting the value may override other desired variables
17421742
but where the variable doesn't also have a corresponding modifying function.
17431743

17441744
Because it's an autoload function, unlike the normal load system, it's loaded

doc/AutoPairsTrouble.txt

Lines changed: 9 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -224,34 +224,15 @@ otherwise
224224

225225
See also: https://github.com/LunarWatcher/auto-pairs/issues/66
226226

227-
Due to the way Vim's input system works, if you map `<CR>` to configure
228-
auto-complete insertions, you can and will see auto-pairs act weirdly if
229-
|g:AutoPairsMapCR| is set.
230-
231-
There's a large number of auto-complete plugins, and a large number of
232-
different systems. Several modern auto-complete plugins are additionally
233-
async, which adds a layer of complexity.
234-
235-
The execution order of auto-pairs and auto-complete plugins, though
236-
particularly coc.nvim has been demonstrated to do this, isn't deterministic.
237-
coc's timeout may or may not fire in time for auto-pairs to have completed,
238-
and if it fires before auto-pairs has a chance to do anything, `pumvisible()`
239-
or similar isn't viable.
240-
241-
Simply put, the pum may have closed by the time auto-pairs is executed. Simply
242-
put, there's no easy way to fix this behavior.
243-
244-
Workarounds~
245-
246-
The first option is disabling |g:AutoPairsMapCR|, and changing your map to
247-
incorporate `\<cr>\<C-r>=autopairs#Keybinds#IgnoreInsertEnter('autopairs#AutoPairsReturn')\<cr>`
248-
into your mapping. Auto-pairs simply wasn't meant for this type of use, so
249-
yes, the command is nasty. This has to be as the fallback to the pum being
250-
visible for a custom `<CR>` map. This is left as an exercise to the reader.
251-
252-
Alternative B... stop using `<CR>` to insert the completion match, and get
253-
used to <C-y>, which is a default Vim mapping for completion insertion. Or, of
254-
course, map completion insertion to an altogether different key.
227+
There's no known reason why auto-pairs misbehaves when <CR> is remapped to
228+
allow for `<CR>` to pick an autocomplete option. See the linked issue
229+
for debug instructions that would help me narrow this down if you're currently
230+
running into this issue.
231+
232+
Note that there previously was an incorrect explanation for the error both
233+
in this section of the help document, and the issue. That explanation was
234+
based on a blatant misunderstanding. See also |autopairs-bad-cr| for a general
235+
problem description, as well as roughly the same troubleshooting steps
255236

256237
==============================================================================
257238
7. Test failures (and related errors) *autopairs-test-failures*

doc/PluginCompatibility.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ vague, the implementation details are unclear and therefore not implemented.
3737

3838
That being said, due to the use of keybinds that do conflict with the plugin,
3939
such as |<cr>| and potentially others, depending on various mapping details,
40-
VM may produce warnings. It's adviced that you suppress these, as they're
40+
VM may produce warnings. It's advised that you suppress these, as they're
4141
unavoidable at the time of writing. The warnings may be suppressed with: >
4242
let g:VM_show_warnings = 0
4343
<

0 commit comments

Comments
 (0)