wincent / command-t

⌨️ Fast file navigation for Neovim and Vim
BSD 2-Clause "Simplified" License
2.74k stars 317 forks source link

Error detected while processing function commandt#HelpFinder: Vim(nunmap):E31: No such mapping #354

Closed parmort closed 5 years ago

parmort commented 5 years ago

Just installed CommandT. I'm getting this error when I open up vim and run CommandT list command (:CommandT, :CommandTMRU, :CommandTHelp, etc.) twice (run any command, close; run any command, error). After that, the error doesn't pop up again until after I open up vim again. OS: ArchLinux NVim: 0.4.0 Ruby: 2.6.2-p47

Here's the stack trace:

No matching autocommands
ruby/2.6.0/gems/neovim-0.8.0/lib/neovim/session.rb:72:in `block in request'
ruby/2.6.0/gems/neovim-0.8.0/lib/neovim/session.rb:117:in `main_thread_only'
ruby/2.6.0/gems/neovim-0.8.0/lib/neovim/session.rb:55:in `request'
ruby/2.6.0/gems/neovim-0.8.0/lib/neovim/api.rb:84:in `call'
ruby/2.6.0/gems/neovim-0.8.0/lib/neovim/client.rb:35:in `method_missing'
ruby/2.6.0/gems/neovim-0.8.0/lib/neovim/ruby_provider/vim.rb:19:in `public_send'
ruby/2.6.0/gems/neovim-0.8.0/lib/neovim/ruby_provider/vim.rb:19:in `method_missing'
plugged/command-t/ruby/command-t/lib/command-t/settings.rb:90:in `set_bool'
plugged/command-t/ruby/command-t/lib/command-t/settings.rb:58:in `set'
plugged/command-t/ruby/command-t/lib/command-t/match_window.rb:319:in `set'
plugged/command-t/ruby/command-t/lib/command-t/match_window.rb:30:in `initialize'
plugged/command-t/ruby/command-t/lib/command-t/controller.rb:366:in `new'
plugged/command-t/ruby/command-t/lib/command-t/controller.rb:366:in `show'
plugged/command-t/ruby/command-t/lib/command-t/controller.rb:81:in `show_help_finder'
(eval):3:in `show_help_finder'
eval:1:in `<main>'
ruby/2.6.0/gems/neovim-0.8.0/lib/neovim/ruby_provider.rb:45:in `eval'
ruby/2.6.0/gems/neovim-0.8.0/lib/neovim/ruby_provider.rb:45:in `block (2 levels) in __define_ruby_execute'
ruby/2.6.0/gems/neovim-0.8.0/lib/neovim/ruby_provider.rb:101:in `block (2 levels) in __wrap_client'
ruby/2.6.0/gems/neovim-0.8.0/lib/neovim/ruby_provider.rb:123:in `__with_std_streams'
ruby/2.6.0/gems/neovim-0.8.0/lib/neovim/ruby_provider.rb:100:in `block in __wrap_client'
ruby/2.6.0/gems/neovim-0.8.0/lib/neovim/ruby_provider.rb:109:in `__with_exception_handling'
ruby/2.6.0/gems/neovim-0.8.0/lib/neovim/ruby_provider.rb:99:in `__wrap_client'
ruby/2.6.0/gems/neovim-0.8.0/lib/neovim/ruby_provider.rb:44:in `block in __define_ruby_execute'
ruby/2.6.0/gems/neovim-0.8.0/lib/neovim/plugin/handler.rb:51:in `call'
ruby/2.6.0/gems/neovim-0.8.0/lib/neovim/host.rb:98:in `block in wrap_plugin_handler'
ruby/2.6.0/gems/neovim-0.8.0/lib/neovim/host.rb:36:in `handle'
ruby/2.6.0/gems/neovim-0.8.0/lib/neovim/host.rb:28:in `block in run'
Error detected while processing function commandt#HelpFinder:
line    2:
RuntimeError: Vim(nunmap):E31: No such mapping

I tried following the trace, but I couldn't find any call to Vim(nunmap) anywhere, nor any parameters that would make the command.

wincent commented 5 years ago

Hm. Thanks for the report @parmort. Quite mysterious. There are two fishy things here:

So I'm suspecting some clash with some other plug-in or config that you've got in your local environment. You could try turning a few things off and trying to isolate the culprit: if you can figure out which thing it is, then we can probably figure out a proper mitigation.

parmort commented 5 years ago

OK, here's what I've found. The conflict is with romainl/vim-cool. I'll look into the code and see what I find, but removing that plugin removes the error.

parmort commented 5 years ago

Ok. Just looking at vim-cool's code, vim-cool maps <Plug>(StopHL), then unmaps it. Is command-t somehow executing that command? I'm saying that because the nunmap is going through nvim's ruby bindings, but vim-cool is written in vimscript.

wincent commented 5 years ago

I see. So it is firing an autocmd on OptionSet here, and that is running when Command-T temporarily sets 'hlsearch' here.

So you could try out a patch like this to Command-T to stop that from happening:

diff --git a/ruby/command-t/lib/command-t/settings.rb b/ruby/command-t/lib/command-t/settings.rb
index 1777bc1..35ab258 100644
--- a/ruby/command-t/lib/command-t/settings.rb
+++ b/ruby/command-t/lib/command-t/settings.rb
@@ -87,12 +87,12 @@ def global?(setting)
     def set_bool(setting, value)
       command = global?(setting) ? 'set' : 'setlocal'
       setting = value ? setting : "no#{setting}"
-      ::VIM::command "#{command} #{setting}"
+      ::VIM::command "noautocmd #{command} #{setting}"
     end

     def set_number(setting, value)
       command = global?(setting) ? 'set' : 'setlocal'
-      ::VIM::command "#{command} #{setting}=#{value}"
+      ::VIM::command "noautocmd #{command} #{setting}=#{value}"
     end
     alias set_string set_number
   end

This might have some unintended side-effects, but it may ok. I might run with this for a while and if it doesn't seem to break anything we can merge it.

parmort commented 5 years ago

Just applied, and it seems to work fine. Will reopen and report if there are any problems, but closing for now. Thanks!