This commit is contained in:
Simon Cambier 2025-06-21 15:34:05 +02:00
parent d34c06e57a
commit 960b0260f9
13 changed files with 38 additions and 179 deletions

View File

@ -1,32 +0,0 @@
---
name: Bug report
about: Create a report to help us improve
title: "[BUG] "
labels: ''
assignees: ''
---
<!-- PLEASE FILL THIS TEMPLATE -->
<!-- If you don't fill it, I'll ask you to fill it before looking at your issue -->
**Problem description:**
<!-- Describe your problem in details. -->
<!-- If applicable, you can copy-paste the console logs (ctrl+shift+i in Obsidian) -->
<!-- and attach screenshots -->
**Your environment:**
<!-- Please, if possible and before filing an issue, -->
<!-- make sure that you have the latest available version of Omnisearch. -->
- 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:

View File

@ -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.**
<!-- A clear and concise description of what the problem is. Ex. I'm always frustrated when [...] -->
**Describe the solution you'd like**
<!-- A clear and concise description of what you want to happen. -->
**Describe alternatives you've considered**
<!-- A clear and concise description of any alternative solutions or features you've considered. -->
**Additional context**
<!-- Add any other context or screenshots about the feature request here. -->

View File

@ -6,7 +6,7 @@ on:
- "*"
env:
PLUGIN_NAME: omnisearch
PLUGIN_NAME: locator
DIST_FOLDER: ./dist
jobs:

View File

@ -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

View File

@ -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;
}

View File

@ -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": {

View File

@ -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

View File

@ -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, {

View File

@ -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.`)
}

View File

@ -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)

View File

@ -97,7 +97,6 @@ export function getDefaultSettings(app: App): LocatorSettings {
maxEmbeds: 5,
renderLineReturnInExcerpts: true,
showCreateButton: false,
showPreviousQueryResults: true,
simpleSearch: false,
fuzziness: '1',

View File

@ -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"')

View File

@ -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 */