Skip to content
Browse files

Merge branch 'add-rules-to-input-triple-quotes'

Close gh-32.
  • Loading branch information...
2 parents 763e62d + 7d19a86 commit b29e05e9574547fb1623b26cca572b13e7616f5e @kana committed Mar 29, 2012
Showing with 138 additions and 0 deletions.
  1. +21 −0 autoload/smartinput.vim
  2. +117 −0 t/api.vim
View
21 autoload/smartinput.vim
@@ -101,20 +101,38 @@ function! smartinput#define_default_rules() "{{{2
\ {'at': '''''\%#', 'char': '<BS>', 'input': '<BS><BS>'},
\ {'at': '\\\%#', 'char': '''', 'input': ''''},
\ ])
+ call urules.add('''''''', [
+ \ {'at': '''''\%#', 'char': '''', 'input': '''''''''<Left><Left><Left>'},
+ \ {'at': '\%#''''''\ze', 'char': '''', 'input': '<Right><Right><Right>'},
+ \ {'at': '''''''\%#''''''', 'char': '<BS>', 'input': '<BS><BS><BS><Del><Del><Del>'},
+ \ {'at': '''''''''''''\%#', 'char': '<BS>', 'input': '<BS><BS><BS><BS><BS><BS>'},
+ \ ])
call urules.add('""', [
\ {'at': '\%#', 'char': '"', 'input': '""<Left>'},
\ {'at': '\%#"', 'char': '"', 'input': '<Right>'},
\ {'at': '"\%#"', 'char': '<BS>', 'input': '<BS><Del>'},
\ {'at': '""\%#', 'char': '<BS>', 'input': '<BS><BS>'},
\ {'at': '\\\%#', 'char': '"', 'input': '"'},
\ ])
+ call urules.add('"""', [
+ \ {'at': '""\%#', 'char': '"', 'input': '""""<Left><Left><Left>'},
+ \ {'at': '\%#"""', 'char': '"', 'input': '<Right><Right><Right>'},
+ \ {'at': '"""\%#"""', 'char': '<BS>', 'input': '<BS><BS><BS><Del><Del><Del>'},
+ \ {'at': '""""""\%#', 'char': '<BS>', 'input': '<BS><BS><BS><BS><BS><BS>'},
+ \ ])
call urules.add('``', [
\ {'at': '\%#', 'char': '`', 'input': '``<Left>'},
\ {'at': '\%#`', 'char': '`', 'input': '<Right>'},
\ {'at': '`\%#`', 'char': '<BS>', 'input': '<BS><Del>'},
\ {'at': '``\%#', 'char': '<BS>', 'input': '<BS><BS>'},
\ {'at': '\\\%#', 'char': '`', 'input': '`'},
\ ])
+ call urules.add('```', [
+ \ {'at': '``\%#', 'char': '`', 'input': '````<Left><Left><Left>'},
+ \ {'at': '\%#```', 'char': '`', 'input': '<Right><Right><Right>'},
+ \ {'at': '```\%#```', 'char': '<BS>', 'input': '<BS><BS><BS><Del><Del><Del>'},
+ \ {'at': '``````\%#', 'char': '<BS>', 'input': '<BS><BS><BS><BS><BS><BS>'},
+ \ ])
call urules.add('English', [
\ {'at': '\w\%#', 'char': '''', 'input': ''''},
\ ])
@@ -132,8 +150,11 @@ function! smartinput#define_default_rules() "{{{2
\ urules.table['[]'],
\ urules.table['{}'],
\ urules.table[''''''],
+ \ urules.table[''''''''],
\ urules.table['""'],
+ \ urules.table['"""'],
\ urules.table['``'],
+ \ urules.table['```'],
\ urules.table['English'],
\ ],
\ 'lisp': [
View
117 t/api.vim
@@ -565,6 +565,40 @@ describe 'The default configuration'
\ ["\"", ['x""'], 1, 4 - 1],
\ ["\<BS>", ['x'], 1, 2 - 1],
\ ],
+ \ '""" complete': [
+ \ ["\"", ['""'], 1, 2 - 1],
+ \ ["\"", ['""'], 1, 3 - 1],
+ \ ["\"", ['""""""'], 1, 4 - 1],
+ \ ],
+ \ '""" leave #1': [
+ \ ["\"", ['""'], 1, 2 - 1],
+ \ ["\"", ['""'], 1, 3 - 1],
+ \ ["\"", ['""""""'], 1, 4 - 1],
+ \ ["\"", ['""""""'], 1, 7 - 1],
+ \ ],
+ \ '""" leave #2': [
+ \ ["\"", ['""'], 1, 2 - 1],
+ \ ["\"", ['""'], 1, 3 - 1],
+ \ ["\"", ['""""""'], 1, 4 - 1],
+ \ ["x", ['"""x"""'], 1, 5 - 1],
+ \ ["\"", ['"""x"""'], 1, 8 - 1],
+ \ ],
+ \ '""" undo #1': [
+ \ ["\"", ['""'], 1, 2 - 1],
+ \ ["\"", ['""'], 1, 3 - 1],
+ \ ["\"", ['""""""'], 1, 4 - 1],
+ \ ["x", ['"""x"""'], 1, 5 - 1],
+ \ ["\<BS>", ['""""""'], 1, 4 - 1],
+ \ ["\<BS>", [''], 1, 0 + 1],
+ \ ],
+ \ '""" undo #2': [
+ \ ["x", ['x'], 1, 2 - 1],
+ \ ["\"", ['x""'], 1, 3 - 1],
+ \ ["\"", ['x""'], 1, 4 - 1],
+ \ ["\"", ['x""""""'], 1, 5 - 1],
+ \ ["\<End>", ['x""""""'], 1, 8 - 1],
+ \ ["\<BS>", ['x'], 1, 2 - 1],
+ \ ],
\ '''''': [
\ ["'", [''''''], 1, 2 - 1],
\ ["'", [''''''], 1, 3 - 1],
@@ -605,6 +639,40 @@ describe 'The default configuration'
\ ["\<C-v>'", ['x'''''], 1, 4 - 1],
\ ["\<BS>", ['x'], 1, 2 - 1],
\ ],
+ \ ''''''' complete': [
+ \ ["'", [''''''], 1, 2 - 1],
+ \ ["'", [''''''], 1, 3 - 1],
+ \ ["'", [''''''''''''''], 1, 4 - 1],
+ \ ],
+ \ ''''''' leave #1': [
+ \ ["'", [''''''], 1, 2 - 1],
+ \ ["'", [''''''], 1, 3 - 1],
+ \ ["'", [''''''''''''''], 1, 4 - 1],
+ \ ["'", [''''''''''''''], 1, 7 - 1],
+ \ ],
+ \ ''''''' leave #2': [
+ \ ["'", [''''''], 1, 2 - 1],
+ \ ["'", [''''''], 1, 3 - 1],
+ \ ["'", [''''''''''''''], 1, 4 - 1],
+ \ ["x", ['''''''x'''''''], 1, 5 - 1],
+ \ ["'", ['''''''x'''''''], 1, 8 - 1],
+ \ ],
+ \ ''''''' undo #1': [
+ \ ["'", [''''''], 1, 2 - 1],
+ \ ["'", [''''''], 1, 3 - 1],
+ \ ["'", [''''''''''''''], 1, 4 - 1],
+ \ ["x", ['''''''x'''''''], 1, 5 - 1],
+ \ ["\<BS>", [''''''''''''''], 1, 4 - 1],
+ \ ["\<BS>", [''], 1, 0 + 1],
+ \ ],
+ \ ''''''' undo #2': [
+ \ ["x", ['x'], 1, 2 - 1],
+ \ ["\<C-v>'", ['x'''], 1, 3 - 1],
+ \ ["\<C-v>'", ['x'''''], 1, 4 - 1],
+ \ ["'", ['x'''''''''''''], 1, 5 - 1],
+ \ ["\<End>", ['x'''''''''''''], 1, 8 - 1],
+ \ ["\<BS>", ['x'], 1, 2 - 1],
+ \ ],
\ '() complete': [
\ ["(", ['()'], 1, 2 - 1],
\ ],
@@ -697,6 +765,40 @@ describe 'The default configuration'
\ ["`", ['x``'], 1, 4 - 1],
\ ["\<BS>", ['x'], 1, 2 - 1],
\ ],
+ \ '``` complete': [
+ \ ["`", ['``'], 1, 2 - 1],
+ \ ["`", ['``'], 1, 3 - 1],
+ \ ["`", ['``````'], 1, 4 - 1],
+ \ ],
+ \ '``` leave #1': [
+ \ ["`", ['``'], 1, 2 - 1],
+ \ ["`", ['``'], 1, 3 - 1],
+ \ ["`", ['``````'], 1, 4 - 1],
+ \ ["`", ['``````'], 1, 7 - 1],
+ \ ],
+ \ '``` leave #2': [
+ \ ["`", ['``'], 1, 2 - 1],
+ \ ["`", ['``'], 1, 3 - 1],
+ \ ["`", ['``````'], 1, 4 - 1],
+ \ ["x", ['```x```'], 1, 5 - 1],
+ \ ["`", ['```x```'], 1, 8 - 1],
+ \ ],
+ \ '``` undo #1': [
+ \ ["`", ['``'], 1, 2 - 1],
+ \ ["`", ['``'], 1, 3 - 1],
+ \ ["`", ['``````'], 1, 4 - 1],
+ \ ["x", ['```x```'], 1, 5 - 1],
+ \ ["\<BS>", ['``````'], 1, 4 - 1],
+ \ ["\<BS>", [''], 1, 0 + 1],
+ \ ],
+ \ '``` undo #2': [
+ \ ["x", ['x'], 1, 2 - 1],
+ \ ["`", ['x``'], 1, 3 - 1],
+ \ ["`", ['x``'], 1, 4 - 1],
+ \ ["`", ['x``````'], 1, 5 - 1],
+ \ ["\<End>", ['x``````'], 1, 8 - 1],
+ \ ["\<BS>", ['x'], 1, 2 - 1],
+ \ ],
\ '{} complete': [
\ ["{", ['{}'], 1, 2 - 1],
\ ],
@@ -783,18 +885,33 @@ describe 'The default configuration'
\ ''''' leave #2',
\ ''''' undo #1',
\ ''''' undo #2',
+ \ ''''''' complete',
+ \ ''''''' leave #1',
+ \ ''''''' leave #2',
+ \ ''''''' undo #1',
+ \ ''''''' undo #2',
\ '"" complete',
\ '"" escape',
\ '"" leave #1',
\ '"" leave #2',
\ '"" undo #1',
\ '"" undo #2',
+ \ '""" complete',
+ \ '""" leave #1',
+ \ '""" leave #2',
+ \ '""" undo #1',
+ \ '""" undo #2',
\ '`` complete',
\ '`` escape',
\ '`` leave #1',
\ '`` leave #2',
\ '`` undo #1',
\ '`` undo #2',
+ \ '``` complete',
+ \ '``` leave #1',
+ \ '``` leave #2',
+ \ '``` undo #1',
+ \ '``` undo #2',
\ 'English',
\ ])
end

0 comments on commit b29e05e

Please sign in to comment.
Something went wrong with that request. Please try again.