mirror of
https://github.com/esm7/obsidian-vimrc-support.git
synced 2026-07-22 05:00:25 +00:00
Another fix to fixed keyboard layout
This commit is contained in:
parent
8f14b0cc96
commit
6c493b804b
4 changed files with 29 additions and 29 deletions
|
|
@ -173,6 +173,9 @@ Relative line numbers work very nicely with [this](https://github.com/nadavspi/o
|
|||
|
||||
## Changelog
|
||||
|
||||
### 0.4.3
|
||||
- Another fix to "fixed keyboard layout in Normal mode".
|
||||
|
||||
### 0.4.2
|
||||
- Attempted fix to https://github.com/esm7/obsidian-vimrc-support/issues/42 (thanks @Andr3wD!)
|
||||
- Fix to "fixed keyboard layout in Normal mode" which was often not really working.
|
||||
|
|
|
|||
51
main.ts
51
main.ts
|
|
@ -84,6 +84,9 @@ export default class VimrcPlugin extends Plugin {
|
|||
}));
|
||||
|
||||
this.app.workspace.on('codemirror', (cm: CodeMirror.Editor) => {
|
||||
cm.on('vim-mode-change', (modeObj: any) => {
|
||||
this.logVimModeChange(modeObj);
|
||||
});
|
||||
this.defineFixedLayout(cm);
|
||||
});
|
||||
|
||||
|
|
@ -107,6 +110,27 @@ export default class VimrcPlugin extends Plugin {
|
|||
await this.saveData(this.settings);
|
||||
}
|
||||
|
||||
logVimModeChange(modeObj: any) {
|
||||
this.isInsertMode = modeObj.mode === 'insert';
|
||||
switch (modeObj.mode) {
|
||||
case "insert":
|
||||
this.currentVimStatus = vimStatus.insert;
|
||||
break;
|
||||
case "normal":
|
||||
this.currentVimStatus = vimStatus.normal;
|
||||
break;
|
||||
case "visual":
|
||||
this.currentVimStatus = vimStatus.visual;
|
||||
break;
|
||||
case "replace":
|
||||
this.currentVimStatus = vimStatus.replace;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
this.vimStatusBar.setText(this.currentVimStatus);
|
||||
}
|
||||
|
||||
onunload() {
|
||||
console.log('unloading Vimrc plugin (but Vim commands that were already loaded will still work)');
|
||||
}
|
||||
|
|
@ -129,10 +153,6 @@ export default class VimrcPlugin extends Plugin {
|
|||
this.defineObCommand(CodeMirror.Vim);
|
||||
this.defineSurround(CodeMirror.Vim);
|
||||
|
||||
CodeMirror.on(cmEditor, "vim-mode-change", (modeObj: any) => {
|
||||
this.isInsertMode = modeObj.mode === 'insert';
|
||||
});
|
||||
|
||||
// Record the position of selections
|
||||
CodeMirror.on(cmEditor, "cursorActivity", async (cm: any) => {
|
||||
this.currentSelection = cm.listSelections()
|
||||
|
|
@ -405,29 +425,6 @@ export default class VimrcPlugin extends Plugin {
|
|||
if (this.settings.displayVimMode) {
|
||||
this.vimStatusBar = this.addStatusBarItem() // Add status bar item
|
||||
this.vimStatusBar.setText(vimStatus.normal) // Init the vimStatusBar with normal mode
|
||||
|
||||
let cmEditor = this.getEditor(this.getActiveView());
|
||||
// See https://codemirror.net/doc/manual.html#vimapi_events for events.
|
||||
CodeMirror.on(cmEditor, "vim-mode-change", async (modeObj: any) => {
|
||||
switch (modeObj.mode) {
|
||||
case "insert":
|
||||
this.currentVimStatus = vimStatus.insert;
|
||||
break;
|
||||
case "normal":
|
||||
this.currentVimStatus = vimStatus.normal;
|
||||
break;
|
||||
case "visual":
|
||||
this.currentVimStatus = vimStatus.visual;
|
||||
break;
|
||||
case "replace":
|
||||
this.currentVimStatus = vimStatus.replace;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
this.vimStatusBar.setText(this.currentVimStatus);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
{
|
||||
"id": "obsidian-vimrc-support",
|
||||
"name": "Vimrc Support",
|
||||
"version": "0.4.2",
|
||||
"version": "0.4.3",
|
||||
"description": "Auto-load a startup file with Obsidian Vim commands.",
|
||||
"author": "esm",
|
||||
"authorUrl": "",
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"name": "obsidian-vimrc-support",
|
||||
"version": "0.4.2",
|
||||
"version": "0.4.3",
|
||||
"description": "Auto-load a startup file with Obsidian Vim commands.",
|
||||
"main": "main.js",
|
||||
"scripts": {
|
||||
|
|
|
|||
Loading…
Reference in a new issue