Add noremap

Adds Code Mirror's noremap command as an ExCommand to enable its use in vimrc
This commit is contained in:
Nadav Spiegelman 2021-01-02 13:50:56 -05:00
parent e171a1ed56
commit 0da1cd76c1

11
main.ts
View file

@ -1,4 +1,5 @@
import { App, Plugin, TFile, MarkdownView } from 'obsidian';
declare const CodeMirror: any;
export default class VimrcPlugin extends Plugin {
private lastYankBuffer = new Array<string>(0);
@ -60,6 +61,16 @@ export default class VimrcPlugin extends Plugin {
}
});
CodeMirror.Vim.defineEx('noremap', '', (cm, params) => {
if (!params?.args?.length) {
throw new Error('Invalid mapping: noremap');
}
if (params.argString.trim()) {
CodeMirror.Vim.noremap.apply(CodeMirror.Vim, params.args);
}
});
vimCommands.split("\n").forEach(
function(line, index, arr) {
if (line.trim().length > 0 && line.trim()[0] != '"') {