Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature: User defined dictionary including 2-chars dict #135

Open
haya14busa opened this issue Mar 31, 2014 · 7 comments
Open

Feature: User defined dictionary including 2-chars dict #135

haya14busa opened this issue Mar 31, 2014 · 7 comments
Labels

Comments

@haya14busa
Copy link
Member

Like migemo & smartsign feature.

let g:EasyMotion_user_dict  = {
            \ 'e' : '[eæœèéêëēėęěə]',
            \ 'nn' : '\v\c(nn|\d\+)',
            \ '??' : '[!"#$%&''()=~|\-^\\@`[\]{};:+*<>,.?_/]',
}
  • e -> match any e like characters
    • if there are already the dictionary like this, please tell me. For Japanese, I can use migemo dictionary` but I don't know any other languages' one.
    • also support a like characters ...
  • nn -> match any digits
  • ?? -> match any signs (regexp & base idea is borrowed from clever-f)
@haya14busa haya14busa changed the title Featuer: User defined dictionary including 2-chars dict Feature: User defined dictionary including 2-chars dict Mar 31, 2014
@haya14busa
Copy link
Member Author

This feature is for find motions. e.g. <Plug>(easymotion-s), <Plug>(easymotion-f), etc..

@haya14busa
Copy link
Member Author

@haya14busa
Copy link
Member Author

Should I consider filetype?

@haya14busa
Copy link
Member Author

Sample?:

let g:EasyMotion_userdict = {
\ '_' : {
\     'dd' : '\d\+'
\   , '??' : '\v[!"#$%&''()=~|\-^\\@`[\]{};:+*<>,.?_/]+'
\   , 'bb' : '\v[()[\]{}]+'
\   , 'ee' : '[eæœèéêëēėęěə]'
\   , 'ww' : '\(\<.\|^$\)'
\   , '$$' : '$'
\   , 'jk' : '^\(\w\|\s*\zs\|$\)'
\   },
\ 'vim' : {
\     'fn' : '\<fu\%[nction]!\=\s\+\%(<[sS][iI][dD]>\|[sSgGbBwWtTlL]:\)\=\%(\i\|[#.]\|{.\{-1,}}\)*\ze\s*('
\   },
\ 'python' : {
\     'fn' : '^\s*def\s\+\h\w*\s*('
\   }
\ }

@DmitryOtroshchenko
Copy link

My use case is jumping to any punctuation sign by typing an easily reachable wildcard character so I have drafted this feature by introducing proxy symbols dictionary:

let g:EasyMotion_proxy_symbols = {';': '!@#$%^&*()-_=+\|:;''"[]{},<.>?/~'}

I use Coleman layout so ; is easily reachable for me.

The implementation is trivial for 1-char substitutions, however I see two possible approaches to implementing the 2-char dictionary feature:

  • Two characters are always two characters, even if they have some matching pattern in g:EasyMotion_user_dict. Thus you can type exactly 2 characters in easymotion-s2 motion. Typing a 2-char combination from a user-defined dictionary will result in matching only the regex from this dictionary. This approach does not require any processing during user input and could be implemented almost as simply as my 1-char g:EasyMotion_proxy_symbols dictionary.
  • Two characters are counted as one logical character if they are found in g:EasyMotion_user_dict. Thus you can type 3 or even 4 characters before triggering easymotion-s2 motion. Given user dictionary:

let g:EasyMotion_userdict = { 'dd' : '\d\+', 'ee' : '[eæœèéêëēėęěə]' }

Typing ddee will match any digit followed by any e-like character. However there exists no way to distinguish ddee from dde apart from triggering motion after some timeout or ENTER. This approach will require modification of EasyMotion command line processing and may be more challenging to implement. In addition it may lead to ambiguous cases.

@haya14busa Could you please tell me the vision of this feature?

@haya14busa
Copy link
Member Author

branch: #135 (comment)

Thank you for the comment 👍
I have no plan to support more than two character. If you want something like that, use https://github.com/haya14busa/incsearch-easymotion.vim and create pattern converter module for incsearch.vim (e.g. https://github.com/haya14busa/incsearch-fuzzy.vim)
n-char search motion considers input as regex, so it's difficult to support user dict feature.

But, we can apply same logic to one-character dict for 2-char search.
I prefer 1-character dict also applies to 2-char search.

@DmitryOtroshchenko
Copy link

I already use incsearch-easymotion and incsearch-fuzzy. Thank you very much for excellent plugins!

I also agree with the simplified approach no mater 1-char or 2-char combination is used: it will permit to avoid ambiguity. Thus with:

let g:EasyMotion_userdict = { 'dd' : '\d\+', 'ee' : '[eæœèéêëēėęěə]' }

dd will be transform into any digit by easymotion-s2 motion.

But how do you imagine using 2-char substitutions in easymotion-f and easymotion-t?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants