Improve the behavior of symbol completion at a middle of a line #34

kana opened this Issue Mar 28, 2012 · 6 comments


None yet
4 participants

kana commented Mar 28, 2012

For example, if the cursor line is foo |bar) (note that | means the cursor position),

  • Should not () be completed if ( is typed at the point?
  • What are appropriate conditions not to complete () etc?
    • \%#$ (at the end of a line) or \%#\K\(.\&\k\@!\) (followed by non-keyword character)?

kana commented Mar 30, 2012

For example...

Expected behavior:

input    | text
{start}  | call smartinput#map_to_trigger(|'<Plug>(physical-key-;)', '<Enter>', '<Enter>')
'        | call smartinput#map_to_trigger('|''<Plug>(physical-key-;)', '<Enter>', '<Enter>')
i        | call smartinput#map_to_trigger('i|''<Plug>(physical-key-;)', '<Enter>', '<Enter>')
'        | call smartinput#map_to_trigger('i'|'<Plug>(physical-key-;)', '<Enter>', '<Enter>')
,<Space> | call smartinput#map_to_trigger('i', |'<Plug>(physical-key-;)', '<Enter>', '<Enter>')

Actual behavior:

input    | text
{start}  | call smartinput#map_to_trigger('<Plug>(physical-key-;)', '<Enter>', '<Enter>')
'        | call smartinput#map_to_trigger('|<Plug>(physical-key-;)', '<Enter>', '<Enter>')
i        | call smartinput#map_to_trigger('i|<Plug>(physical-key-;)', '<Enter>', '<Enter>')
'        | call smartinput#map_to_trigger('i'|<Plug>(physical-key-;)', '<Enter>', '<Enter>')
,<Space> | call smartinput#map_to_trigger('i', <Plug>(physical-key-;)', '<Enter>', '<Enter>')

I have come across this issue a few times now so I thought I'd give you my thoughts on the subject.

My preference is that ( is only completed to () when the character to the right of the cursor is not a space, tab or newline. I find that when the character to the right is not whitespace then I most likely intend to add a single (, do some complex movement, and then insert the ).

I think it is easier to enter insert mode so that the character to the right is whitespace to enable completion than it is to hit Ctrl+v then ( to disable completion.


kana commented Apr 4, 2012

@b4winckler Thank you for the feedback. It's hard to define comfortable rules in most cases. I'll consider the problem later.

grota commented Apr 4, 2012

not sure how, but I think vim's searchpair function might turn useful.

char101 commented Apr 5, 2012

I currently use this custom rules because most of the time when I'm typing parantheses before a word what I want is to wrap that word inside the parantheses

call smartinput#define_rule({'at': '\%#\w', 'char': '(', 'input': '('})
call smartinput#define_rule({'at': '\%#\w', 'char': '[', 'input': '['})
call smartinput#define_rule({'at': '\%#\w', 'char': '{}', 'input': '{'})
call smartinput#define_rule({'at': '\%#\w', 'char': '''', 'input': ''''})
call smartinput#define_rule({'at': '\%#\w', 'char': '"', 'input': '"'})

kana commented Apr 6, 2012

@grota @char101 Thank you for the ideas. I'll consider them later.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment