cohama / lexima.vim

Auto close parentheses and repeat by dot dot dot...
995 stars 46 forks source link

[Feature Request] Add g:lexima_manually_keys #132

Open 4513ECHO opened 2 years ago

4513ECHO commented 2 years ago

Motivation

lexima binds mapping automatically in lexima#add_rule(). But it sometimes comes into conflict with other plugins or configs. We want the way to avoid this problem.

Feature Overview

We can define g:lexima_manually_keys which is list of keys. lexima does not bind to these keys. Users have to use lexima#expand() by thereselves.

Example is here:

let g:lexima_manually_keys = ['$', '<CR>']

call lexima#add_rule({ 'char': '$', 'some': 'config })
call lexima#add_rule({ 'char': '<CR>', 'some': 'config })

inoremap <expr> $ DollarFunc()
cnoremap <expr> <CR> CRFunc()

function! DollarFunc() abort
  if some#condition()
    return some#function()
  endif
  return lexima#expand('$', 'i')
endfunction
cohama commented 2 years ago

I'm not sure why g:lexima_manually_keys is necessary. In your example, inoremap <expr> $ DollarFunc() overrides $ rules defined by lexima.vim.

4513ECHO commented 2 years ago

Yes, surely we can override mappings if we execute *(nore)map after lexima defined rules. However, if lexima is made lazy by plugin manager, understanding "after lexima defined rules" is hard for most users.... It is important for lexima not to bind mappings certainly.

cohama commented 2 years ago

In my opinion, it is hard for most users to understand lazy feature and the best solution to such a situation is to not using lazy feature.

4513ECHO commented 2 years ago

Hmm, your opinion is true. The lazy feature is advanced. However, the most important problem is that lexima define mappings implicitly. There are many related issue in the repository about conflict of mappings. It is serious not also for advanced users but beginners. If the way exists to avoid conflict with other plugins or configs explicitly, we can reduce such problems.

4513ECHO commented 1 year ago

Is there any update on this? If you don't want to include this feature, I'll close this issue. Otherwise I'll send a PR.

cohama commented 1 year ago

I'm sorry to slow response. Yes, I can not believe this feature best solution to solve this problem.

4513ECHO commented 1 year ago

Ok, thanks.

cohama commented 1 year ago

As discussed vim-jp slack, I finally found out that there are some cases adding a rule and resolving conflicts want to be done independently.