This commit is contained in:
Simon Cambier
2023-08-22 08:09:17 +02:00
2 changed files with 18 additions and 2 deletions

View File

@@ -38,7 +38,7 @@ abstract class OmnisearchModal extends Modal {
] as const) { ] as const) {
for (const modifier of ['Ctrl', 'Mod'] as const) { for (const modifier of ['Ctrl', 'Mod'] as const) {
this.scope.register([modifier], key.k, _e => { this.scope.register([modifier], key.k, _e => {
if (this.app.vault.getConfig('vimMode')) { if (settings.vimLikeNavigationShortcut) {
// e.preventDefault() // e.preventDefault()
eventBus.emit('arrow-' + key.dir) eventBus.emit('arrow-' + key.dir)
} }
@@ -53,7 +53,7 @@ abstract class OmnisearchModal extends Modal {
] as const) { ] as const) {
for (const modifier of ['Ctrl', 'Mod'] as const) { for (const modifier of ['Ctrl', 'Mod'] as const) {
this.scope.register([modifier], key.k, _e => { this.scope.register([modifier], key.k, _e => {
if (this.app.vault.getConfig('vimMode')) { if (settings.vimLikeNavigationShortcut) {
// e.preventDefault() // e.preventDefault()
eventBus.emit('arrow-' + key.dir) eventBus.emit('arrow-' + key.dir)
} }

View File

@@ -56,6 +56,7 @@ export interface OmnisearchSettings extends WeightingSettings {
splitCamelCase: boolean splitCamelCase: boolean
openInNewPane: boolean openInNewPane: boolean
verboseLogging: boolean verboseLogging: boolean
vimLikeNavigationShortcut: boolean
fuzziness: '0' | '1' | '2' fuzziness: '0' | '1' | '2'
} }
@@ -263,6 +264,7 @@ export class SettingsTab extends PluginSettingTab {
}) })
) )
// Open in new pane
new Setting(containerEl) new Setting(containerEl)
.setName('Open in new pane') .setName('Open in new pane')
.setDesc( .setDesc(
@@ -275,6 +277,19 @@ export class SettingsTab extends PluginSettingTab {
}) })
) )
// Set Vim like navigation keys
new Setting(containerEl)
.setName('Set Vim like navigation keys')
.setDesc(
'Navigate down the results with Ctrl/⌘ + J/N, or navigate up with Ctrl/⌘ + K/P'
)
.addToggle(toggle =>
toggle.setValue(settings.vimLikeNavigationShortcut).onChange(async v => {
settings.vimLikeNavigationShortcut = v
await saveSettings(this.plugin)
})
)
// Fuzziness // Fuzziness
new Setting(containerEl) new Setting(containerEl)
.setName('Fuzziness') .setName('Fuzziness')
@@ -524,6 +539,7 @@ export const DEFAULT_SETTINGS: OmnisearchSettings = {
unsupportedFilesIndexing: 'no', unsupportedFilesIndexing: 'no',
splitCamelCase: false, splitCamelCase: false,
openInNewPane: false, openInNewPane: false,
vimLikeNavigationShortcut: app.vault.getConfig('vimMode') as boolean,
ribbonIcon: true, ribbonIcon: true,
showExcerpt: true, showExcerpt: true,