Skip to content

Commit

Permalink
Add sample vim extension
Browse files Browse the repository at this point in the history
  • Loading branch information
MaxCan-Code committed Mar 3, 2024
1 parent c549c33 commit 611304a
Show file tree
Hide file tree
Showing 3 changed files with 65 additions and 0 deletions.
26 changes: 26 additions & 0 deletions sample-extensions/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions sample-extensions/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"dependencies": {
"monaco-vim": "^0.4.1"
}
}
34 changes: 34 additions & 0 deletions sample-extensions/vim.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
//To use this extension:
// copy this file to the userData dir as in https://dyalog.github.io/ride/4.5/customising_your_session:
// (package.json and package-lock.json are there for reference)
// - Linux: `$HOME/.config/Ride-<version>`
// - macOS: `$HOME/Library/Application Support/Ride-<version>` (hidden directory – access from the command line)
// - Microsoft Windows: `%APPDATA%\Ride-<version>`
// npm install --prefix /dir/to/this/file monaco-vim
// export RIDE_JS=/path/to/this/file.js
//before starting RIDE.
$.extend(D.commands, {
VIM(me) {
amdRequire(
[ "vs/editor/editor.main",
D.el.app.getPath("userData") + "/node_modules/monaco-vim/dist/monaco-vim", ],
function (a, MonacoVim) { vimMode = MonacoVim.initVimMode(me, document.createElement("div")); },
);
me.updateOptions({ lineNumbers: "relative" });
},
MIV() { vimMode.dispose(); },
});
D.remDefaultMap = (me) => { // hijack to run additional code on startup
const kbs = me._standaloneKeybindingService;
kbs.addDynamicKeybinding( "-editor.action.insertCursorAtEndOfEachLineSelected", null, () => {}, );
kbs.addDynamicKeybinding("-editor.action.blockComment", null, () => {});
kbs.addDynamicKeybinding("-editor.action.formatDocument", null, () => {});
D.commands.VIM(me);
};
$.extend(D.Ed.prototype, {
setLN(x) { // update the display of line numbers and the state of the "[...]" button
const ed = this;
ed.me.updateOptions({ lineNumbers: "relative" });
ed.dom.querySelector(".tb_LN").classList.toggle("pressed", !!x);
},
});

0 comments on commit 611304a

Please sign in to comment.