Add ability to downrank some folders in the results (#350)

* add downrankedFoldersFilters to settings

* use downrankedFoldersFilters to downrank some files without excluding them in obsidian, which also prevents tags from being indexed

* change hotkey for toggling excerpts to ctrl-g

* change var to let for proper scoping

* trim folders after splitting them

* only log downranking when we actually do it

* format with Prettier

* make prompt-instruction-command still ctrl g for now
This commit is contained in:
eegrok
2024-03-15 06:36:23 +13:00
committed by GitHub
parent c66c65cdc2
commit 72cb4216c0
3 changed files with 56 additions and 1 deletions

View File

@@ -29,6 +29,8 @@ export interface OmnisearchSettings extends WeightingSettings {
useCache: boolean
/** Respect the "excluded files" Obsidian setting by downranking results ignored files */
hideExcluded: boolean
/** downrank files in the given folders */
downrankedFoldersFilters: string[]
/** Ignore diacritics when indexing files */
ignoreDiacritics: boolean
/** Extensions of plain text files to index, in addition to .md */
@@ -268,6 +270,24 @@ export class SettingsTab extends PluginSettingTab {
})
)
// Downranked files
new Setting(containerEl)
.setName('Folders to downrank in search results')
.setDesc(
`Folders to downrank in search results. Files in these folders will be downranked in results. They will still be indexed for tags, unlike excluded files. Folders should be comma delimited.`
)
.addText(component => {
component
.setValue(settings.downrankedFoldersFilters.join(','))
.setPlaceholder('Example: src,p2/dir')
.onChange(async v => {
let folders = v.split(',')
folders = folders.map(f => f.trim())
settings.downrankedFoldersFilters = folders
await saveSettings(this.plugin)
})
})
// Split CamelCaseWords
const camelCaseDesc = new DocumentFragment()
camelCaseDesc.createSpan({}, span => {
@@ -621,6 +641,7 @@ export class SettingsTab extends PluginSettingTab {
export const DEFAULT_SETTINGS: OmnisearchSettings = {
useCache: true,
hideExcluded: false,
downrankedFoldersFilters: [] as string[],
ignoreDiacritics: true,
indexedFileTypes: [] as string[],
PDFIndexing: false,