-
Notifications
You must be signed in to change notification settings - Fork 3
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
Compatibility issues with built in Vim #13
Comments
I tried to figure out a way I could use a shortcut key to run a macro that first send a keypress of the letter a and then does the vimium: show markers command but I could not find a way to send that letter a keypress |
A silly method that just crossed my mind would be to prepend A in front of all the generated vimium markers using css |
Hi there!) function isEditingWithVim(app) {
const activeLeaf = app.workspace.activeLeaf;
if (!activeLeaf) return false;
const view = activeLeaf.view;
console.log(view)
// Check source mode
if (view.getMode() === "source") {
const editorEl = document.querySelector('.vimrc-support-vim-mode');
return editorEl?.getAttribute('data-vim-mode') === "insert";
}
return false;
}
function simulateKeyPress(targetElement, key, code, keyCode) {
const eventInit = {
key: key,
code: code,
keyCode: keyCode,
which: keyCode,
bubbles: true,
cancelable: true,
composed: true
};
// keydown event
const keydownEvent = new KeyboardEvent("keydown", eventInit);
targetElement.dispatchEvent(keydownEvent);
// keyup event
const keyupEvent = new KeyboardEvent("keyup", eventInit);
targetElement.dispatchEvent(keyupEvent);
}
createMarkers() {
// patch for vim visual mode (just enter to editor mode)
// note - MARKERS SELECTIONS NOT WORK in visual mode
if (isEditingWithVim(this.app)) {
console.log("Редактор находится в режиме редактирования и вставки (Vim Insert Mode).");
} else {
simulateKeyPress(document.activeElement || document, "i", "KeyI", 73);
console.log("Редактор либо не в режиме редактирования, либо не в режиме вставки.");
}
... |
So I really like this plugin and want to keep using it but when running it alongside the built in VIM keybindings it cause an annoying issue:
If I call vimium: show markers then they show up but whatever I press does not get captured by vimium because the VIM keybindings capture it first and do not allow passthrough. The only way I can get vimium to capture the key strokes is to press a first to get into insert mode and then call vimium: show markers.
Is there any way this extra step can be removed? Its most problematic when I'm in a area where there is no insert mode possibility like a side panel.
Maybe making the vimium event listener higher priority than vim?
The text was updated successfully, but these errors were encountered: