mirror of
https://github.com/esm7/obsidian-vimrc-support.git
synced 2026-07-22 05:00:25 +00:00
Add settings tab
This commit is contained in:
parent
760953695e
commit
8f8b163615
1 changed files with 38 additions and 2 deletions
40
main.ts
40
main.ts
|
|
@ -1,14 +1,25 @@
|
|||
import { App, Plugin, TFile, MarkdownView } from 'obsidian';
|
||||
import { App, Plugin, TFile, MarkdownView, PluginSettingTab, Setting } from 'obsidian';
|
||||
declare const CodeMirror: any;
|
||||
|
||||
interface Settings {
|
||||
}
|
||||
|
||||
const DEFAULT_SETTINGS: Settings = {
|
||||
}
|
||||
|
||||
export default class VimrcPlugin extends Plugin {
|
||||
settings: Settings;
|
||||
|
||||
private lastYankBuffer = new Array<string>(0);
|
||||
private lastSystemClipboard = "";
|
||||
private yankToSystemClipboard: boolean = false;
|
||||
|
||||
onload() {
|
||||
async onload() {
|
||||
console.log('loading Vimrc plugin');
|
||||
|
||||
await this.loadSettings();
|
||||
this.addSettingTab(new SettingsTab(this.app, this))
|
||||
|
||||
this.registerEvent(this.app.workspace.on('file-open', (file: TFile) => {
|
||||
const VIMRC_FILE_NAME = '.obsidian.vimrc';
|
||||
this.app.vault.adapter.read(VIMRC_FILE_NAME).
|
||||
|
|
@ -27,6 +38,15 @@ export default class VimrcPlugin extends Plugin {
|
|||
})
|
||||
}
|
||||
|
||||
async loadSettings(){
|
||||
const data = await this.loadData();
|
||||
this.settings = Object.assign({}, DEFAULT_SETTINGS, data);
|
||||
}
|
||||
|
||||
async saveSettings(){
|
||||
await this.saveData(this.settings);
|
||||
}
|
||||
|
||||
onunload() {
|
||||
console.log('unloading Vimrc plugin (but Vim commands that were already loaded will still work)');
|
||||
}
|
||||
|
|
@ -110,3 +130,19 @@ export default class VimrcPlugin extends Plugin {
|
|||
}
|
||||
}
|
||||
|
||||
class SettingsTab extends PluginSettingTab {
|
||||
plugin: VimrcPlugin;
|
||||
|
||||
constructor(app: App, plugin: VimrcPlugin) {
|
||||
super(app, plugin);
|
||||
this.plugin = plugin;
|
||||
}
|
||||
|
||||
display(): void {
|
||||
let {containerEl} = this;
|
||||
|
||||
containerEl.empty();
|
||||
|
||||
containerEl.createEl('h2', {text: 'Obsidian Vimrc Support Settings'});
|
||||
}
|
||||
}
|
||||
Loading…
Reference in a new issue