Skip to content

Commit

Permalink
Base feature set for completing #335
Browse files Browse the repository at this point in the history
Needs tests and a couple minor tweaks for automatically disabling, but should be good.

And in case the feature suggester reads this commit, sorry it took a couple days, my workload didn't balance out nicely :')
  • Loading branch information
LunarWatcher committed Aug 27, 2021
1 parent 73849e2 commit d5c3669
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 0 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

* Code cleanup
* Vimscript standard update #1
* Skip single completion ([jiangmiao#335](https://github.com/jiangmiao/auto-pairs/issues/335))

# 3.0.0-beta12
`let g:AutoPairsVersion = 30057`
Expand Down
15 changes: 15 additions & 0 deletions autoload/autopairs.vim
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,9 @@ endf

func! autopairs#AutoPairsInsert(key, ...)
if !b:autopairs_enabled
return "\<SPACE>"
elseif b:AutoPairsIgnoreSingle
let b:AutoPairsIgnoreSingle = 0
return a:key
end

Expand Down Expand Up @@ -282,6 +285,9 @@ endf

func! autopairs#AutoPairsDelete()
if !b:autopairs_enabled
return "\<SPACE>"
elseif b:AutoPairsIgnoreSingle
let b:AutoPairsIgnoreSingle = 0
return "\<BS>"
end

Expand Down Expand Up @@ -548,6 +554,9 @@ endf
func! autopairs#AutoPairsSpace()
if !b:autopairs_enabled
return "\<SPACE>"
elseif b:AutoPairsIgnoreSingle
let b:AutoPairsIgnoreSingle = 0
return "\<SPACE>"
end

let [before, after, ig] = autopairs#Strings#getline()
Expand Down Expand Up @@ -588,6 +597,12 @@ func! autopairs#AutoPairsToggle()
return ''
endf

func! autopairs#AutoPairsIgnore()
let b:AutoPairsIgnoreSingle = !b:AutoPairsIgnoreSingle
echo (b:AutoPairsIgnoreSingle ? "Skipping next pair" : "Not skipping next pair")
return ''
endfunc

fun! autopairs#AutoPairsToggleMultilineClose()
let b:AutoPairsMultilineClose = !b:AutoPairsMultilineClose
echo (b:AutoPairsMultilineClose ? "Enabled" : "Disabled") "multiline close"
Expand Down
4 changes: 4 additions & 0 deletions autoload/autopairs/Keybinds.vim
Original file line number Diff line number Diff line change
Expand Up @@ -269,4 +269,8 @@ fun! autopairs#Keybinds#mapKeys()
execute 'inoremap <buffer> <silent> ' . b:AutoPairsShortcutJump . ' <ESC>:call autopairs#AutoPairsJump()<CR>a'
execute 'noremap <buffer> <silent> ' . b:AutoPairsShortcutJump . ' :call autopairs#AutoPairsJump()<CR>'
end

if b:AutoPairsShortcutIgnore != ''
execute 'inoremap <buffer> <silent> ' .. b:AutoPairsShortcutIgnore .. ' <C-r>=autopairs#AutoPairsIgnore()<cr>'
end
endfun
4 changes: 4 additions & 0 deletions autoload/autopairs/Variables.vim
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ fun! autopairs#Variables#_InitVariables()
call s:define('g:AutoPairsCenterLine', 1)

call s:define('g:AutoPairsShortcutToggle', g:AutoPairsCompatibleMaps ? '<M-p>': '<C-p><C-t>')
call s:define("g:AutoPairsShortcutIgnore", '<C-e>')
call s:define('g:AutoPairsShortcutFastWrap', g:AutoPairsCompatibleMaps ? '<M-e>' : '<C-f>')

call s:define('g:AutoPairsMoveCharacter', "()[]{}\"'")
Expand Down Expand Up @@ -164,4 +165,7 @@ fun! autopairs#Variables#_InitBufferVariables()
call s:define('b:AutoPairsShortcutToggle', g:AutoPairsShortcutToggle)
call s:define('b:AutoPairsShortcutJump', g:AutoPairsShortcutJump)
call s:define('b:AutoPairsShortcutToggleMultilineClose', g:AutoPairsShortcutToggleMultilineClose)
call s:define("b:AutoPairsShortcutIgnore", g:AutoPairsShortcutIgnore)

call s:define("b:AutoPairsIgnoreSingle", 0)
endfun

1 comment on commit d5c3669

@LunarWatcher
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ugh, unlinking the fork of course means #335 doesn't complete to jiangmiao/auto-pairs#335. oh well

Please sign in to comment.