mirror of
https://github.com/esm7/obsidian-vimrc-support.git
synced 2026-07-22 05:00:25 +00:00
Small fixes
This commit is contained in:
parent
da3b85d317
commit
b701827d74
4 changed files with 27 additions and 3 deletions
|
|
@ -34,6 +34,7 @@ I couldn't find a formal list anywhere but you can look for `defaultExCommandMap
|
|||
In addition to that:
|
||||
- The plugin skips blank lines and lines starting with Vimscript comments (`" ...`).
|
||||
- Special support for yanking to system clipboard can be activated by `set clipboard=unnamed` (`unnamedplus` will do the same thing).
|
||||
- Support for the `tabstop` Vim option (e.g. `set tabstop=4`).
|
||||
|
||||
Commands that fail don't generate any visible error for now.
|
||||
|
||||
|
|
@ -54,6 +55,11 @@ Things I'd love to add:
|
|||
|
||||
## Changelog
|
||||
|
||||
### 0.2.1
|
||||
|
||||
- Fixed [this issue](https://github.com/esm7/obsidian-vimrc-support/issues/7): setting `clipboard=unnamed` also works for pasting now (it monitors the system clipboard and updates the yank buffer if a change is detected).
|
||||
- Support for the `tabstop` Vim option as asked [here](https://github.com/esm7/obsidian-vimrc-support/issues/3).
|
||||
|
||||
### 0.2.0
|
||||
|
||||
Added support for yanking to system clipboard (see above), comments and blank lines.
|
||||
|
|
|
|||
20
main.ts
20
main.ts
|
|
@ -2,6 +2,7 @@ import { App, Plugin, TFile, MarkdownView } from 'obsidian';
|
|||
|
||||
export default class VimrcPlugin extends Plugin {
|
||||
private lastYankBuffer = new Array<string>(0);
|
||||
private lastSystemClipboard = "";
|
||||
private yankToSystemClipboard: boolean = false;
|
||||
|
||||
onload() {
|
||||
|
|
@ -17,10 +18,12 @@ export default class VimrcPlugin extends Plugin {
|
|||
this.registerDomEvent(document, 'click', () => {
|
||||
this.captureYankBuffer();
|
||||
});
|
||||
|
||||
this.registerDomEvent(document, 'keyup', () => {
|
||||
this.captureYankBuffer();
|
||||
});
|
||||
this.registerDomEvent(document, 'focusin', () => {
|
||||
this.captureYankBuffer();
|
||||
})
|
||||
}
|
||||
|
||||
onunload() {
|
||||
|
|
@ -45,6 +48,11 @@ export default class VimrcPlugin extends Plugin {
|
|||
}
|
||||
}
|
||||
});
|
||||
CodeMirror.Vim.defineOption('tabstop', 4, 'number', [], (value, cm) => {
|
||||
if (value) {
|
||||
cmEditor.setOption('tabSize', value);
|
||||
}
|
||||
});
|
||||
|
||||
vimCommands.split("\n").forEach(
|
||||
function(line, index, arr) {
|
||||
|
|
@ -67,9 +75,19 @@ export default class VimrcPlugin extends Plugin {
|
|||
if (currentBuffer != this.lastYankBuffer) {
|
||||
if (this.lastYankBuffer.length > 0 && currentBuffer.length > 0 && currentBuffer[0]) {
|
||||
navigator.clipboard.writeText(currentBuffer[0]);
|
||||
this.lastSystemClipboard = currentBuffer[0];
|
||||
}
|
||||
this.lastYankBuffer = currentBuffer;
|
||||
return;
|
||||
}
|
||||
let currentClipboard = navigator.clipboard.readText().then((value) => {
|
||||
if (value != this.lastSystemClipboard) {
|
||||
let yankRegister = CodeMirror.Vim.getRegisterController().getRegister('yank')
|
||||
yankRegister.setText(value);
|
||||
this.lastYankBuffer = yankRegister.keyBuffer;
|
||||
this.lastSystemClipboard = value;
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
{
|
||||
"id": "obsidian-vimrc-support",
|
||||
"name": "Obsidian Vimrc Support",
|
||||
"version": "0.2.0",
|
||||
"version": "0.2.1",
|
||||
"description": "Auto-load a startup file with Obsidian Vim commands.",
|
||||
"author": "esm",
|
||||
"authorUrl": "",
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"name": "obsidian-vimrc-support",
|
||||
"version": "0.2.0",
|
||||
"version": "0.2.1",
|
||||
"description": "Auto-load a startup file with Obsidian Vim commands.",
|
||||
"main": "main.js",
|
||||
"scripts": {
|
||||
|
|
|
|||
Loading…
Reference in a new issue