From 960b0260f92c204d325d84863aa94cc6817d635e Mon Sep 17 00:00:00 2001 From: Simon Cambier Date: Sat, 21 Jun 2025 15:34:05 +0200 Subject: [PATCH] cleaning --- .github/ISSUE_TEMPLATE/bug_report.md | 32 ---------- .github/ISSUE_TEMPLATE/feature_request.md | 20 ------- .github/workflows/release.yml | 2 +- README.md | 3 +- assets/styles.css | 44 +++++++------- package.json | 5 +- pnpm-lock.yaml | 73 ----------------------- src/components/modals.ts | 6 +- src/main.ts | 1 + src/search/tokenizer.ts | 17 +++--- src/settings/index.ts | 1 - src/settings/settings-behavior.ts | 11 ---- src/settings/utils.ts | 2 - 13 files changed, 38 insertions(+), 179 deletions(-) delete mode 100644 .github/ISSUE_TEMPLATE/bug_report.md delete mode 100644 .github/ISSUE_TEMPLATE/feature_request.md diff --git a/.github/ISSUE_TEMPLATE/bug_report.md b/.github/ISSUE_TEMPLATE/bug_report.md deleted file mode 100644 index 30576a7..0000000 --- a/.github/ISSUE_TEMPLATE/bug_report.md +++ /dev/null @@ -1,32 +0,0 @@ ---- -name: Bug report -about: Create a report to help us improve -title: "[BUG] " -labels: '' -assignees: '' ---- - - - - -**Problem description:** - - - - - -**Your environment:** - - - - -- Omnisearch version: -- Obsidian version: -- Operating system: -- Number of indexed documents in your vault (approx.): - -**Things to try:** - -- Does the problem occur when Omnisearch is the only active community plugin: -- Does the problem occur when you _don't_ index PDFs, images, or other non-notes files: -- Does the problem occur after a cache reset: diff --git a/.github/ISSUE_TEMPLATE/feature_request.md b/.github/ISSUE_TEMPLATE/feature_request.md deleted file mode 100644 index 09e640e..0000000 --- a/.github/ISSUE_TEMPLATE/feature_request.md +++ /dev/null @@ -1,20 +0,0 @@ ---- -name: Feature request -about: Suggest an idea for this project -title: "[Feature request]" -labels: '' -assignees: '' - ---- - -**Is your feature request related to a problem? Please describe.** - - -**Describe the solution you'd like** - - -**Describe alternatives you've considered** - - -**Additional context** - diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 03c0981..d917ebc 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -6,7 +6,7 @@ on: - "*" env: - PLUGIN_NAME: omnisearch + PLUGIN_NAME: locator DIST_FOLDER: ./dist jobs: diff --git a/README.md b/README.md index 25a70eb..ef0fc76 100644 --- a/README.md +++ b/README.md @@ -4,12 +4,13 @@ --- -**Locator** is an Obsidian plugin that lets you locate your files in a few keystrokes. It is a lightweight version of Omnisearch. +**Locator** is an Obsidian plugin that lets you locate your files in a few keystrokes. It is a lightweight, experimental version of Omnisearch. It always instantly shows you the most relevant results, thanks to its smart weighting algorithm. Under the hood, it uses the excellent [MiniSearch](https://github.com/lucaong/minisearch) library. + ![](https://raw.githubusercontent.com/scambier/obsidian-omnisearch/master/images/omnisearch.gif) ## Installation diff --git a/assets/styles.css b/assets/styles.css index 8b0c6c6..ae54a0b 100644 --- a/assets/styles.css +++ b/assets/styles.css @@ -1,7 +1,7 @@ -.omnisearch-modal { +.locator-modal { } -.omnisearch-result { +.locator-result { white-space: normal; display: flex; flex-direction: row; @@ -9,7 +9,7 @@ flex-wrap: nowrap; } -.omnisearch-result__title-container { +.locator-result__title-container { display: flex; align-items: center; justify-content: space-between; @@ -17,17 +17,17 @@ flex-wrap: wrap; } -.omnisearch-result__title { +.locator-result__title { white-space: pre-wrap; align-items: center; display: flex; gap: 5px; } -.omnisearch-result__title > span { +.locator-result__title > span { } -.omnisearch-result__folder-path { +.locator-result__folder-path { font-size: 0.75rem; align-items: center; display: flex; @@ -35,17 +35,17 @@ color: var(--text-muted); } -.omnisearch-result__extension { +.locator-result__extension { font-size: 0.7rem; color: var(--text-muted); } -.omnisearch-result__counter { +.locator-result__counter { font-size: 0.7rem; color: var(--text-muted); } -.omnisearch-result__body { +.locator-result__body { white-space: normal; font-size: small; word-wrap: normal; @@ -59,20 +59,20 @@ margin-inline-start: 0.5em; } -.omnisearch-result__embed { +.locator-result__embed { margin-left: 1em; } -.omnisearch-result__image-container { +.locator-result__image-container { flex-basis: 20%; text-align: end; } -.omnisearch-highlight { +.locator-highlight { } -.omnisearch-default-highlight { +.locator-default-highlight { text-decoration: underline; text-decoration-color: var(--text-highlight-bg); text-decoration-thickness: 3px; @@ -80,14 +80,14 @@ text-decoration-skip-ink: none; } -.omnisearch-input-container { +.locator-input-container { display: flex; align-items: center; flex-direction: row; gap: 5px; } -.omnisearch-result__icon { +.locator-result__icon { display: inline-block; vertical-align: middle; width: 16px; @@ -95,41 +95,41 @@ margin-right: 4px; } -.omnisearch-result__icon svg { +.locator-result__icon svg { width: 100%; height: 100%; } -.omnisearch-result__icon--emoji { +.locator-result__icon--emoji { font-size: 16px; vertical-align: middle; margin-right: 4px; } @media only screen and (max-width: 600px) { - .omnisearch-input-container { + .locator-input-container { flex-direction: column; } - .omnisearch-input-container__buttons { + .locator-input-container__buttons { display: flex; flex-direction: row; width: 100%; padding: 0 1em 0 1em; gap: 1em; } - .omnisearch-input-container__buttons > button { + .locator-input-container__buttons > button { flex-grow: 1; } } @media only screen and (min-width: 600px) { - .omnisearch-input-container__buttons { + .locator-input-container__buttons { margin-inline-end: 1em; } } -.omnisearch-input-field { +.locator-input-field { position: relative; flex-grow: 1; } diff --git a/package.json b/package.json index 7971fc3..23e108c 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "scambier.obsidian-locator", - "version": "1.27.1", + "version": "0.1.0", "description": "Locate your notes in a few keystrokes", "main": "dist/main.js", "scripts": { @@ -47,8 +47,7 @@ "markdown-link-extractor": "^4.0.2", "minisearch": "7.1.0", "pure-md5": "^0.1.14", - "search-query-parser": "^1.6.0", - "svelte-multiselect": "github:janosh/svelte-multiselect" + "search-query-parser": "^1.6.0" }, "pnpm": { "overrides": { diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index a77b103..bd39163 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -32,9 +32,6 @@ importers: search-query-parser: specifier: ^1.6.0 version: 1.6.0 - svelte-multiselect: - specifier: github:janosh/svelte-multiselect - version: https://codeload.github.com/janosh/svelte-multiselect/tar.gz/91f22d0cafdf931607288d18c5268badd358d83b devDependencies: '@babel/preset-env': specifier: ^7.26.9 @@ -1424,9 +1421,6 @@ packages: resolution: {integrity: sha512-QVb0dM5HvG+uaxitm8wONl7jltx8dqhfU33DcqtOZcLSVIKSDDLDi7+0LbAKiyI8hD9u42m2YxXSkMGWThaecQ==} engines: {iojs: '>= 1.0.0', node: '>= 0.12.0'} - code-red@1.0.4: - resolution: {integrity: sha512-7qJWqItLA8/VPVlKJlFXU+NBlo/qyfs39aJcuMT/2ere32ZqvF5OSxgdM5xOfJJ7O429gg2HM47y8v9P+9wrNw==} - collect-v8-coverage@1.0.2: resolution: {integrity: sha512-lHl4d5/ONEbLlJvaJNtsF/Lz+WvB07u2ycqTYbdrq7UypDXailES4valYb2eWiJFxZlVmpGekfqoxQhzyFdT4Q==} @@ -1471,10 +1465,6 @@ packages: css-select@5.1.0: resolution: {integrity: sha512-nwoRF1rvRRnnCqqY7updORDsuqKzqYJ28+oSMaJMMgOauh3fvwHqMS7EZpIPqK8GL+g9mKxF1vP/ZjSeNjEVHg==} - css-tree@2.3.1: - resolution: {integrity: sha512-6Fv1DV/TYw//QF5IzQdqsNDjx/wc8TrMBZsqjL9eW01tWb7R7k/mq+/VXfJCl7SoD5emsJop9cOByJZfs8hYIw==} - engines: {node: ^10 || ^12.20.0 || ^14.13.0 || >=15.0.0} - css-what@6.1.0: resolution: {integrity: sha512-HTUrgRJ7r4dsZKU6GjmpfRK1O76h97Z8MfS1G0FozR+oF2kG6Vfe8JE6zwrkbxigziPHinCJ+gCPjA9EaBDtRw==} engines: {node: '>= 6'} @@ -1836,9 +1826,6 @@ packages: estree-walker@2.0.2: resolution: {integrity: sha512-Rfkk/Mp/DL7JVje3u18FxFujQlTNR2q6QfMSMB7AvCBx91NGj/ba3kCfza0f6dVDbw7YlRf/nDrn7pQrCCyQ/w==} - estree-walker@3.0.3: - resolution: {integrity: sha512-7RUKfXgSMMkzt6ZuXmqapOurLGPPfgj6l9uRZ7lRGolvk0y2yocc35LdcxKC5PQZdn2DMqioAQ2NoWcrTKmm6g==} - esutils@2.0.3: resolution: {integrity: sha512-kVscqXk4OCp68SZ0dkgEKVi6/8ij300KBWTJq32P/dYeWTSwK41WyTxalN1eRmA5Z9UU/LX9D7FWSmV9SAYx6g==} engines: {node: '>=0.10.0'} @@ -2376,9 +2363,6 @@ packages: resolution: {integrity: sha512-/IXtbwEk5HTPyEwyKX6hGkYXxM9nbj64B+ilVJnC/R6B0pH5G4V3b0pVbL7DBj4tkhBAppbQUlf6F6Xl9LHu1g==} engines: {node: '>= 0.4'} - mdn-data@2.0.30: - resolution: {integrity: sha512-GaqWWShW4kv/G9IEucWScBx9G1/vsFZZJUO+tD26M8J8z3Kw5RDQjaoZe03YAClgeS/SWPOcb4nkFBTEi5DUEA==} - merge-stream@2.0.0: resolution: {integrity: sha512-abv/qOcuPfk3URPfDzmZU1LKmuw8kT+0nIHvKrKgFrwifol/doWcdA4ZqsWQ8ENrFKkd67Mfpo/LovbIUsbt3w==} @@ -2542,9 +2526,6 @@ packages: resolution: {integrity: sha512-gDKb8aZMDeD/tZWs9P6+q0J9Mwkdl6xMV8TjnGP3qJVJ06bdMgkbBlLU8IdfOsIsFz2BW1rNVT3XuNEl8zPAvw==} engines: {node: '>=8'} - periscopic@3.1.0: - resolution: {integrity: sha512-vKiQ8RRtkl9P+r/+oefh25C3fhybptkHKCZSPlcXiJux2tJF55GnEj3BVn4A5gKfq9NWWXXrxkHBwVPUfH0opw==} - picocolors@1.1.1: resolution: {integrity: sha512-xceH2snhtb5M9liqDsmEw56le376mTZkEX/jEb/RxNFyegNul7eNslCXP9FDj/Lcu0X8KEyMceP2ntpaHrDEVA==} @@ -2887,10 +2868,6 @@ packages: jest: '>= 27' svelte: '>= 3' - svelte-multiselect@https://codeload.github.com/janosh/svelte-multiselect/tar.gz/91f22d0cafdf931607288d18c5268badd358d83b: - resolution: {tarball: https://codeload.github.com/janosh/svelte-multiselect/tar.gz/91f22d0cafdf931607288d18c5268badd358d83b} - version: 11.0.0-rc.1 - svelte-preprocess@6.0.3: resolution: {integrity: sha512-PLG2k05qHdhmRG7zR/dyo5qKvakhm8IJ+hD2eFRQmMLHp7X3eJnjeupUtvuRpbNiF31RjVw45W+abDwHEmP5OA==} engines: {node: '>= 18.0.0'} @@ -2928,10 +2905,6 @@ packages: typescript: optional: true - svelte@4.2.12: - resolution: {integrity: sha512-d8+wsh5TfPwqVzbm4/HCXC783/KPHV60NvwitJnyTA5lWn1elhXMNWhXGCJ7PwPa8qFUnyJNIyuIRt2mT0WMug==} - engines: {node: '>=16'} - svelte@5.23.2: resolution: {integrity: sha512-PHP1o0aYJNMatiZ+0nq1W/Z1W1/l5Z94B9nhMIo7gsuTBbxC454g4O5SQMjQpZBUZi5ANYUrXJOE4gPzcN/VQw==} engines: {node: '>=18'} @@ -4714,14 +4687,6 @@ snapshots: co@4.6.0: {} - code-red@1.0.4: - dependencies: - '@jridgewell/sourcemap-codec': 1.5.0 - '@types/estree': 1.0.6 - acorn: 8.14.1 - estree-walker: 3.0.3 - periscopic: 3.1.0 - collect-v8-coverage@1.0.2: {} color-convert@2.0.1: @@ -4764,11 +4729,6 @@ snapshots: domutils: 3.2.2 nth-check: 2.1.1 - css-tree@2.3.1: - dependencies: - mdn-data: 2.0.30 - source-map-js: 1.2.1 - css-what@6.1.0: {} css.escape@1.5.1: {} @@ -5099,10 +5059,6 @@ snapshots: estree-walker@2.0.2: {} - estree-walker@3.0.3: - dependencies: - '@types/estree': 1.0.6 - esutils@2.0.3: {} execa@5.1.1: @@ -5885,8 +5841,6 @@ snapshots: math-intrinsics@1.1.0: {} - mdn-data@2.0.30: {} - merge-stream@2.0.0: {} merge2@1.4.1: {} @@ -6034,12 +5988,6 @@ snapshots: path-type@4.0.0: {} - periscopic@3.1.0: - dependencies: - '@types/estree': 1.0.6 - estree-walker: 3.0.3 - is-reference: 3.0.3 - picocolors@1.1.1: {} picomatch@2.3.1: {} @@ -6364,10 +6312,6 @@ snapshots: jest: 27.5.1 svelte: 5.23.2 - svelte-multiselect@https://codeload.github.com/janosh/svelte-multiselect/tar.gz/91f22d0cafdf931607288d18c5268badd358d83b: - dependencies: - svelte: 4.2.12 - svelte-preprocess@6.0.3(@babel/core@7.26.10)(postcss@8.5.3)(sass@1.86.0)(svelte@5.23.2)(typescript@5.8.2): dependencies: svelte: 5.23.2 @@ -6377,23 +6321,6 @@ snapshots: sass: 1.86.0 typescript: 5.8.2 - svelte@4.2.12: - dependencies: - '@ampproject/remapping': 2.3.0 - '@jridgewell/sourcemap-codec': 1.5.0 - '@jridgewell/trace-mapping': 0.3.25 - '@types/estree': 1.0.6 - acorn: 8.14.1 - aria-query: 5.3.2 - axobject-query: 4.1.0 - code-red: 1.0.4 - css-tree: 2.3.1 - estree-walker: 3.0.3 - is-reference: 3.0.3 - locate-character: 3.0.0 - magic-string: 0.30.17 - periscopic: 3.1.0 - svelte@5.23.2: dependencies: '@ampproject/remapping': 2.3.0 diff --git a/src/components/modals.ts b/src/components/modals.ts index 1912a04..5ec9376 100644 --- a/src/components/modals.ts +++ b/src/components/modals.ts @@ -164,10 +164,8 @@ export class LocatorVaultModal extends LocatorModal { ?.editor.getSelection() plugin.searchHistory.getHistory().then(history => { - // Previously searched query (if enabled in settings) - const previous = plugin.settings.showPreviousQueryResults - ? history[0] - : null + // Previously searched query + const previous = history[0] // Instantiate and display the Svelte component const cmp = mount(ModalVault, { diff --git a/src/main.ts b/src/main.ts index ac88b4e..c27a732 100644 --- a/src/main.ts +++ b/src/main.ts @@ -274,6 +274,7 @@ export default class LocatorPlugin extends Plugin { } console.timeEnd('Indexing total time') + console.log(`Indexed ${diff.toAdd.length} files, removed ${diff.toRemove.length} files`) if (diff.toAdd.length >= 1000 && isCacheEnabled()) { new Notice(`Your files have been indexed.`) } diff --git a/src/search/tokenizer.ts b/src/search/tokenizer.ts index bc83a41..8bfbecc 100644 --- a/src/search/tokenizer.ts +++ b/src/search/tokenizer.ts @@ -16,9 +16,11 @@ export class Tokenizer { */ public tokenizeForIndexing(text: string): string[] { try { - const words = this.tokenizeWords(text) + const lang = eld.detectLanguage(text) + console.log(lang) + const words = this.tokenizeIntoWords(text) + let tokens = this.tokenizeIntoTokens(text, { skipChs: true }) - let tokens = this.tokenizeTokens(text, { skipChs: true }) tokens = [ ...tokens.flatMap(token => [ token, @@ -28,9 +30,6 @@ export class Tokenizer { ...words, ] - // Remove duplicates - tokens = [...new Set(tokens)] - return tokens } catch (e) { console.error('Error tokenizing text, skipping document', e) @@ -49,7 +48,7 @@ export class Tokenizer { const urls: string[] = markdownLinkExtractor(text) text = urls.reduce((acc, url) => acc.replace(url, ''), text) - const tokens = [...this.tokenizeTokens(text), ...urls].filter(Boolean) + const tokens = [...this.tokenizeIntoTokens(text), ...urls].filter(Boolean) return { combineWith: 'OR', @@ -57,7 +56,7 @@ export class Tokenizer { { combineWith: 'AND', queries: tokens }, { combineWith: 'AND', - queries: this.tokenizeWords(text).filter(Boolean), + queries: this.tokenizeIntoWords(text).filter(Boolean), }, { combineWith: 'AND', queries: tokens.flatMap(splitHyphens) }, { combineWith: 'AND', queries: tokens.flatMap(splitCamelCase) }, @@ -65,13 +64,13 @@ export class Tokenizer { } } - private tokenizeWords(text: string, { skipChs = false } = {}): string[] { + private tokenizeIntoWords(text: string, { skipChs = false } = {}): string[] { const tokens = text.split(BRACKETS_AND_SPACE) if (skipChs) return tokens return this.tokenizeChsWord(tokens) } - private tokenizeTokens(text: string, { skipChs = false } = {}): string[] { + private tokenizeIntoTokens(text: string, { skipChs = false } = {}): string[] { const tokens = text.split(SPACE_OR_PUNCTUATION) if (skipChs) return tokens return this.tokenizeChsWord(tokens) diff --git a/src/settings/index.ts b/src/settings/index.ts index dcd42c6..1095e2e 100644 --- a/src/settings/index.ts +++ b/src/settings/index.ts @@ -97,7 +97,6 @@ export function getDefaultSettings(app: App): LocatorSettings { maxEmbeds: 5, renderLineReturnInExcerpts: true, showCreateButton: false, - showPreviousQueryResults: true, simpleSearch: false, fuzziness: '1', diff --git a/src/settings/settings-behavior.ts b/src/settings/settings-behavior.ts index 43ffb54..c511332 100644 --- a/src/settings/settings-behavior.ts +++ b/src/settings/settings-behavior.ts @@ -27,17 +27,6 @@ export function injectSettingsBehavior( }) ) - // Show previous query results - new Setting(containerEl) - .setName('Show previous query results') - .setDesc('Re-executes the previous query when opening Locator.') - .addToggle(toggle => - toggle.setValue(settings.showPreviousQueryResults).onChange(async v => { - settings.showPreviousQueryResults = v - await saveSettings(plugin) - }) - ) - // Respect excluded files new Setting(containerEl) .setName('Respect Obsidian\'s "Excluded Files"') diff --git a/src/settings/utils.ts b/src/settings/utils.ts index f9ec18c..7b22db8 100644 --- a/src/settings/utils.ts +++ b/src/settings/utils.ts @@ -68,8 +68,6 @@ export interface LocatorSettings extends WeightingSettings { renderLineReturnInExcerpts: boolean /** Enable a "create note" button in the Vault Search modal */ showCreateButton: boolean - /** Re-execute the last query when opening Locator */ - showPreviousQueryResults: boolean /** Key for the welcome message when Obsidian is updated. A message is only shown once. */ welcomeMessage: string /** If a query returns 0 result, try again with more relax conditions */