inkdropapp / inkdrop-vim

Provides Vim modal control for Inkdrop, blending the best of Vim and Inkdrop
https://www.inkdrop.app/
MIT License
99 stars 9 forks source link

Add clearSerchHighlight to vimApi #21

Closed basyura closed 4 years ago

basyura commented 4 years ago

hi.

inkdrop is so nice! and vim plugin so nice!

I want to clear search highlight by escape key in normal mode. So, I create PR to access vimApi from init.js .

If this PR is merged, I define my command in init.js and keymap.cson .

inkdrop.commands.add(document.body, "mycmd:reset-normal-mode", () => {
  inkdrop.commands.dispatch(document.body, "vim:reset-normal-mode");
  const cm = inkdrop.getActiveEditor().cm;
  const vim = inkdrop.packages.activePackages.vim.mainModule.vim;
  vim.clearSearchHighlight(cm);
});
'.CodeMirror.vim-mode.normal-mode textarea':
   'escape': 'mycmd:reset-normal-mode'

Or is there another good way?

thanks!

craftzdog commented 4 years ago

Hi basyura-san,

Thanks for the PR. You can clear search highlightings by running the following code:

vim.exCommandDispatcher.processCommand(cm, "nohlsearch")

It will run the nohlsearch ex-command defined here, calling internally clearSearchHighlight. Hope that helps you customize it :)

basyura commented 4 years ago

I can run the nohlsearch , thanks!