Skip to content
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

Draft: implement vim keymap (Resolves Issue #24) #51

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion electron/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ const schema = {
settings: {
type: "object",
properties: {
"keymap": { "enum": ["default", "emacs"], default:"default" },
"keymap": { "enum": ["default", "emacs", "vim"], default:"default" },
"emacsMetaKey": { "enum": [null, "alt", "meta"], default: null },
"showLineNumberGutter": {type: "boolean", default:true},
"showFoldGutter": {type: "boolean", default:true},
Expand Down
34 changes: 18 additions & 16 deletions package-lock.json

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

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@
"vue-tsc": "^1.0.16"
},
"dependencies": {
"@replit/codemirror-vim": "^6.1.0",
"electron-log": "^5.0.1"
}
}
1 change: 1 addition & 0 deletions src/components/settings/Settings.vue
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
keymaps: [
{ name: "Default", value: "default" },
{ name: "Emacs", value: "emacs" },
{ name: "Vim", value: "vim"},
],
keymap: this.initialSettings.keymap,
metaKey: this.initialSettings.emacsMetaKey,
Expand Down
3 changes: 3 additions & 0 deletions src/editor/editor.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import { noteBlockExtension, blockLineNumbers } from "./block/block.js"
import { changeCurrentBlockLanguage, triggerCurrenciesLoaded } from "./block/commands.js"
import { formatBlockContent } from "./block/format-code.js"
import { heynoteKeymap } from "./keymap.js"
import { vimKeymap } from "./keymap.js"
import { emacsKeymap } from "./emacs.js"
import { heynoteCopyPaste } from "./copy-paste"
import { languageDetection } from "./language-detection/autodetect.js"
Expand All @@ -24,6 +25,8 @@ export const LANGUAGE_SELECTOR_EVENT = "openLanguageSelector"
function getKeymapExtensions(editor, keymap) {
if (keymap === "emacs") {
return emacsKeymap(editor)
} else if (keymap === "vim") {
return vimKeymap(editor)
} else {
return heynoteKeymap(editor)
}
Expand Down
10 changes: 10 additions & 0 deletions src/editor/keymap.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { keymap } from "@codemirror/view"
import { Vim, vim } from "@replit/codemirror-vim"
//import { EditorSelection, EditorState } from "@codemirror/state"
import {
indentLess, indentMore,
Expand Down Expand Up @@ -53,3 +54,12 @@ export function heynoteKeymap(editor) {
{key:"Ctrl-ArrowDown", run:gotoNextParagraph, shift:selectNextParagraph},
])
}

export function vimKeymap(editor) {
//Vim.defineEx("DeleteLineFix", (editor) => {
//editor.view.cm.execCommand("deleteLine")
//})

//Vim.map("\\\\", ":DeleteLineFix", "normal")
return [heynoteKeymap(editor), vim()]
}