mirror of
https://github.com/esm7/obsidian-vimrc-support.git
synced 2026-07-22 05:00:25 +00:00
Removal of CM5 support and some cleanups
This commit is contained in:
parent
ab34da73f5
commit
9a0376745e
3 changed files with 38 additions and 34 deletions
55
README.md
55
README.md
|
|
@ -38,31 +38,6 @@ exmap forward obcommand app:go-forward
|
|||
nmap <C-i> :forward
|
||||
```
|
||||
|
||||
## Emulate Common Vim Commands via Obsidian commands
|
||||
|
||||
Using `obcommand`, it is possible to emulate some additional vim commands that aren't included in Obsidian's vim mode, like for example `gt` and and `zo`.
|
||||
|
||||
```vim
|
||||
" Emulate Folding https://vimhelp.org/fold.txt.html#fold-commands
|
||||
exmap togglefold obcommand editor:toggle-fold
|
||||
nmap zo :togglefold
|
||||
nmap zc :togglefold
|
||||
nmap za :togglefold
|
||||
|
||||
exmap unfoldall obcommand editor:unfold-all
|
||||
nmap zR :unfoldall
|
||||
|
||||
exmap foldall obcommand editor:fold-all
|
||||
nmap zM :foldall
|
||||
|
||||
" Emulate Tab Switching https://vimhelp.org/tabpage.txt.html#gt
|
||||
" requires Cycle Through Panes Plugins https://obsidian.md/plugins?id=cycle-through-panes
|
||||
exmap tabnext obcommand cycle-through-panes:cycle-through-panes
|
||||
nmap gt :tabnext
|
||||
exmap tabprev obcommand cycle-through-panes:cycle-through-panes-reverse
|
||||
nmap gT :tabprev
|
||||
```
|
||||
|
||||
## Supported Commands
|
||||
|
||||
The commands that can be used are whatever CodeMirror supports.
|
||||
|
|
@ -186,6 +161,32 @@ map <A-p> :pasteinto
|
|||
But first `<Space>` must be unbound with `unmap <Space>`.
|
||||
Afterwards `<Space>` can be mapped normally as any other key.
|
||||
|
||||
|
||||
## Emulate Common Vim Commands via Obsidian commands
|
||||
|
||||
Using `obcommand`, it is possible to emulate some additional Vim commands that aren't included in Obsidian's Vim mode, like for example `gt` and `zo`.
|
||||
|
||||
```vim
|
||||
" Emulate Folding https://vimhelp.org/fold.txt.html#fold-commands
|
||||
exmap togglefold obcommand editor:toggle-fold
|
||||
nmap zo :togglefold
|
||||
nmap zc :togglefold
|
||||
nmap za :togglefold
|
||||
|
||||
exmap unfoldall obcommand editor:unfold-all
|
||||
nmap zR :unfoldall
|
||||
|
||||
exmap foldall obcommand editor:fold-all
|
||||
nmap zM :foldall
|
||||
|
||||
" Emulate Tab Switching https://vimhelp.org/tabpage.txt.html#gt
|
||||
" requires Cycle Through Panes Plugins https://obsidian.md/plugins?id=cycle-through-panes
|
||||
exmap tabnext obcommand cycle-through-panes:cycle-through-panes
|
||||
nmap gt :tabnext
|
||||
exmap tabprev obcommand cycle-through-panes:cycle-through-panes-reverse
|
||||
nmap gT :tabprev
|
||||
```
|
||||
|
||||
## Fixed Keyboard Layout in Normal Mode
|
||||
|
||||
**Note:** this is currently unsupported for the new (CM6-based) editor.
|
||||
|
|
@ -261,6 +262,10 @@ See [here](JsSnippets.md) for the full example, and please contribute your own!
|
|||
**IMPORTANT: this version drops support for the legacy (CM5) Obsidian editor.**
|
||||
If you are sticking to the legacy editor until Obsidian removes it, you cannot upgrade to this version of the plugin.
|
||||
|
||||
- Removed support for the legacy (CM5) editor.
|
||||
- This fixes [issues](https://github.com/esm7/obsidian-vimrc-support/issues/118) in the detection of the editor type.
|
||||
- Support for Obsidian 0.15 multi windows (https://github.com/esm7/obsidian-vimrc-support/pull/110).
|
||||
|
||||
### 0.6.3
|
||||
|
||||
Added `selection` also to `jsfile` (thanks @twio142!)
|
||||
|
|
|
|||
15
main.ts
15
main.ts
|
|
@ -1,5 +1,5 @@
|
|||
import * as keyFromAccelerator from 'keyboardevent-from-electron-accelerator';
|
||||
import { Editor, EditorSelection, Notice, App, MarkdownView, Plugin, PluginSettingTab, Setting, TFile } from 'obsidian';
|
||||
import { EditorSelection, Notice, App, MarkdownView, Plugin, PluginSettingTab, Setting, TFile } from 'obsidian';
|
||||
|
||||
declare const CodeMirror: any;
|
||||
|
||||
|
|
@ -43,7 +43,6 @@ export default class VimrcPlugin extends Plugin {
|
|||
settings: Settings;
|
||||
|
||||
private codeMirrorVimObject: any = null;
|
||||
private editorMode: 'cm5' | 'cm6' = null;
|
||||
private initialized = false;
|
||||
|
||||
private lastYankBuffer: string[] = [""];
|
||||
|
|
@ -82,9 +81,9 @@ export default class VimrcPlugin extends Plugin {
|
|||
|
||||
this.codeMirrorVimObject = (window as any).CodeMirrorAdapter?.Vim;
|
||||
|
||||
await this.registerYankEvents(activeWindow)
|
||||
this.registerYankEvents(activeWindow);
|
||||
this.app.workspace.on("window-open", (workspaceWindow, w) => {
|
||||
this.registerYankEvents(w)
|
||||
this.registerYankEvents(w);
|
||||
})
|
||||
|
||||
this.initialized = true;
|
||||
|
|
@ -428,21 +427,21 @@ export default class VimrcPlugin extends Plugin {
|
|||
return
|
||||
}
|
||||
|
||||
const yankRegister = this.codeMirrorVimObject.getRegisterController().getRegister('yank')
|
||||
const yankRegister = this.codeMirrorVimObject.getRegisterController().getRegister('yank');
|
||||
const currentYankBuffer = yankRegister.keyBuffer;
|
||||
|
||||
// yank -> clipboard
|
||||
const buf = currentYankBuffer[0]
|
||||
if (buf !== this.lastYankBuffer[0]) {
|
||||
await win.navigator.clipboard.writeText(buf);
|
||||
this.lastYankBuffer = currentYankBuffer
|
||||
this.lastSystemClipboard = await win.navigator.clipboard.readText()
|
||||
this.lastYankBuffer = currentYankBuffer;
|
||||
this.lastSystemClipboard = await win.navigator.clipboard.readText();
|
||||
return
|
||||
}
|
||||
|
||||
// clipboard -> yank
|
||||
try {
|
||||
const currentClipboardText = await win.navigator.clipboard.readText()
|
||||
const currentClipboardText = await win.navigator.clipboard.readText();
|
||||
if (currentClipboardText !== this.lastSystemClipboard) {
|
||||
yankRegister.setText(currentClipboardText);
|
||||
this.lastYankBuffer = yankRegister.keyBuffer;
|
||||
|
|
|
|||
|
|
@ -17,7 +17,7 @@
|
|||
"@types/node": "^14.14.6",
|
||||
"codemirror": "^5.62.2",
|
||||
"keyboardevent-from-electron-accelerator": "*",
|
||||
"obsidian": "^0.15.3",
|
||||
"obsidian": "^0.15.4",
|
||||
"rollup": "^2.33.0",
|
||||
"tslib": "^2.0.3",
|
||||
"typescript": "^4.0.5"
|
||||
|
|
|
|||
Loading…
Reference in a new issue