Hey, hope your well! To start off the easiest way to do this is to set the hotkey for the ‘show context menu under cursor’ in the obsidian hotkey menu.
I didn’t know that command existed starting off so I spent a little time on the vimrc-support plugin and for the sake of learning I curious if anyone can get this working.
So I just added this code which copies the followLinkUderCursor command:
/**
* Opens context menu at given position.
*/
const openContextMenu = (vimrcPlugin) => {
const obsidianEditor = vimrcPlugin.getActiveObsidianEditor();
const { line, ch } = obsidianEditor.getCursor();
// Get the word at the cursor
const currentWord = obsidianEditor.getRange(
wordAt.from,
wordAt.to,
);
for (const word of currentWord) {
if (word.length > 0) {
obsidianEditor.exec("openContextMenu", {
x: ch,
y: line,
});
}
}
vimrcPlugin.executeObsidianCommand("show-context-menu-under-cursor");
// Move the cursor back to where it was
obsidianEditor.setCursor({ line, ch: ch - numCharsMoved });
};
Then I added it to the defineAndMapObsidianVimCommands
``
defineAndMapObsidianVimCommands(vimObject) {
defineAndMapObsidianVimMotion(vimObject, jumpToNextHeading, ‘]]’);
defineAndMapObsidianVimMotion(vimObject, jumpToPreviousHeading, ‘[[’);
defineAndMapObsidianVimMotion(vimObject, jumpToNextLink, ‘gl’);
defineAndMapObsidianVimMotion(vimObject, jumpToPreviousLink, ‘gL’);
defineAndMapObsidianVimAction(vimObject, this, moveDownSkippingFolds, ‘zj’);
defineAndMapObsidianVimAction(vimObject, this, moveUpSkippingFolds, ‘zk’);
defineAndMapObsidianVimAction(vimObject, this, followLinkUnderCursor, ‘gf’);
defineAndMapObsidianVimAction(vimObject, this, openContextMenu, ‘’);
}
So at this point I was looking into what executeObsidianCommand where built in which got me to just setting the hotkey in the app. It would be still cool to finish up this feature addition to learn how cursors, and vim configs work!
Thanks!