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

Educate just doesn’t switch on automatically #20

Open
mcepl opened this issue Apr 13, 2020 · 15 comments
Open

Educate just doesn’t switch on automatically #20

mcepl opened this issue Apr 13, 2020 · 15 comments
Labels

Comments

@mcepl
Copy link

mcepl commented Apr 13, 2020

No matter whether I rely on default (which is supposed to be that educate is on), or whether I add 'educate': 1 explicitly to the configuration of the plugin), it is always off, and I have to run command :Edcuate every time I start new instance of vim (neovim from the master branch of the git, or vim 8.2.0348, but I have observed it for some time already).

I don’t see any error messages anywhere.

@alerque
Copy link
Member

alerque commented Apr 13, 2020

Can you please post your vim RC code for how you are setting 'educate': 1? I suspect this is just an issue with your usage of autocmd or similar, it definitely works for me. In fact my preference is to have it defaulting to off and enable it manually, and I find I have to be very careful and aggressive about how I set it to 0 to actually keep it off.

@mcepl
Copy link
Author

mcepl commented Apr 13, 2020

Here it is (complete vimrc is on https://gitlab.com/mcepl/vimdir/-/blob/master/vimrc ):

" for vim-textobj-quote
function! TextObjSettings()
  if exists(":Educate")
      if &spelllang =~ 'cs'
         call textobj#quote#init({ 'double':'„“', 'single':'‚‘', 'educate': 1 })
      elseif &spelllang =~ 'en'
         call textobj#quote#init({ 'double':'“”', 'single':'‘’', 'educate': 1 })
      endif
      exe "Educate"
  endif
endfunction
map <silent> <leader>qc <Plug>ReplaceWithCurly

let g:textobj#quote#educate = 1
autocmd OptionSet spelllang call TextObjSettings()
autocmd BufEnter  *.rst     call TextObjSettings()
noremap <buffer> <Leader>sq call TextObjSettings()

@alerque
Copy link
Member

alerque commented Apr 13, 2020

Why are you running exe "Educate" as part of that function?

@mcepl
Copy link
Author

mcepl commented Apr 13, 2020

Why are you running exe "Educate" as part of that function?

One of many desperate attempts to switch educate on?

@joshukraine
Copy link

@mcepl FWIW, I installed this plugin the other day and had the same problem. Found this issue when googling the problem. I could activate Educate manually, but I couldn't get it to come on with the FileType autocmd provided in the documentation. After some trial and error, I discovered that my problem was caused by a conflict with the jiangmiao/auto-pairs plugin. When I removed that plugin, everything worked as expected.

Since I use coc.nvim, I just switched to using the coc-pairs plugin instead. Hope that helps!

@alerque
Copy link
Member

alerque commented Apr 30, 2020

@mcepl Have you tried testing this creating a MWE with just this plugin and nothing else?

@mcepl
Copy link
Author

mcepl commented May 1, 2020

No auto-pairs here.

@alerque
Copy link
Member

alerque commented May 1, 2020

@mcepl Do you mean you don't have auto-pairs or you do? If the latter (as your comma suggests) then I think we can narrow this down to that. If the former, please don't just limit the test to disabling auto-pairs, strip all other plugins to a bare minimum config with just this plugin and see if it still fails.

@mcepl
Copy link
Author

mcepl commented May 1, 2020

Sorry, the comma was a mistake.

@mcepl
Copy link
Author

mcepl commented May 2, 2020

You are right, this is a clash with https://github.com/tmsvg/pear-tree , when I removed that, Educate is suddenly automatically on. Thank you.

@mcepl mcepl closed this as completed May 2, 2020
@alerque
Copy link
Member

alerque commented May 2, 2020

Hmm. I would actually be inclined to keep this open. If we are clashing with multiple other plugins (in this case both plugins doing a similar thing) we (or they) might be doing something wrong. I don't think these necessarily need to conflict, or at least could do so more gracefully.

@mcepl
Copy link
Author

mcepl commented May 3, 2020

OK

@mcepl mcepl reopened this May 3, 2020
@alerque alerque added the bug label May 12, 2020
@alerque
Copy link
Member

alerque commented May 12, 2020

Hey @tmsvg or @jiangmiao do either of you happen to have an idea off the top of your head why a plugin like this would conflict or what should be done about it. I imagine there is a hook somewhere both plugins are trying to grab and that we should check if it has been previously utilized, but I'm not quite sure where to start.

@ferki
Copy link

ferki commented Feb 12, 2022

vim-textobj-quote and the other plugins mentioned here (auto-pairs, pear-tree) are using inoremap to map various keypresses in insert mode to execute their own functions. I believe that results in a bad interaction if multiple plugins want to define what should happen for the same keypress (e.g. ' and ").

I'm not sure how that could be fixed in a proper way, but as a workaround, I started to make sure only one of these plugins take control for a given key. For example, the auto-pairs plugin can be configured per file type to handle only a subset of keypresses instead of its default list:

autocmd FileType markdown let b:AutoPairs = { '(':')', '[':']', '`':'`', '```':'```' }
autocmd FileType mail let b:AutoPairs = { '(':')', '[':']', '`':'`' }

In other words, I can describe that I'm fine to only auto-pair (, [, ` and ``` keys/sequences while editing markdown files, and only (, [, and ` while editing mail. That way the auto-pairs plugin doesn't map the ' and " keys for its own purposes, leaving vim-textobj-quote to do its own thing.

I wonder if there's a good way to somehow let these mappings to be chained 🤔 E.g. let vim-textobj-quote to replace straight quote " with curly quote , and then let auto-pairs insert its curly pair resulting in “”.

@alerque
Copy link
Member

alerque commented Feb 12, 2022

I'm sure we could figure out some sort of handoff, bit it might take some fiddling and cooperation for both sides with a hook / callback of some sort since the trigger event isn't quite what the other side normally handles.

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

4 participants