mirror of
https://github.com/huhu/rust-search-extension
synced 2024-11-14 15:47:12 +00:00
Show search hint
This commit is contained in:
parent
85da5da028
commit
f5b8eb2a56
2 changed files with 13 additions and 3 deletions
2
core
2
core
|
@ -1 +1 @@
|
||||||
Subproject commit 6f2927eda9973f8d105a2cad0d0187689f4547c7
|
Subproject commit 88a20de012b14883138aeae46beb58941c476b85
|
|
@ -167,6 +167,7 @@ async function start(omnibox) {
|
||||||
|
|
||||||
// Nightly std docs search
|
// Nightly std docs search
|
||||||
omnibox.addPrefixQueryEvent("/", {
|
omnibox.addPrefixQueryEvent("/", {
|
||||||
|
name: "Nightly docs",
|
||||||
onSearch: (query) => {
|
onSearch: (query) => {
|
||||||
query = query.replaceAll("/", "").trim();
|
query = query.replaceAll("/", "").trim();
|
||||||
return nightlySearcher.search(query);
|
return nightlySearcher.search(query);
|
||||||
|
@ -185,6 +186,7 @@ async function start(omnibox) {
|
||||||
});
|
});
|
||||||
|
|
||||||
omnibox.addPrefixQueryEvent("~", {
|
omnibox.addPrefixQueryEvent("~", {
|
||||||
|
name: "External docs",
|
||||||
isDefaultSearch: () => {
|
isDefaultSearch: () => {
|
||||||
return defaultSearch.thirdPartyDocs;
|
return defaultSearch.thirdPartyDocs;
|
||||||
},
|
},
|
||||||
|
@ -196,6 +198,7 @@ async function start(omnibox) {
|
||||||
});
|
});
|
||||||
|
|
||||||
omnibox.addPrefixQueryEvent("@", {
|
omnibox.addPrefixQueryEvent("@", {
|
||||||
|
name: "Crate docs",
|
||||||
onSearch: async (query) => {
|
onSearch: async (query) => {
|
||||||
return await crateDocSearcher.search(query);
|
return await crateDocSearcher.search(query);
|
||||||
},
|
},
|
||||||
|
@ -234,6 +237,7 @@ async function start(omnibox) {
|
||||||
}
|
}
|
||||||
|
|
||||||
omnibox.addPrefixQueryEvent("!", {
|
omnibox.addPrefixQueryEvent("!", {
|
||||||
|
name: "docs.rs",
|
||||||
isDefaultSearch: () => {
|
isDefaultSearch: () => {
|
||||||
return defaultSearch.docsRs;
|
return defaultSearch.docsRs;
|
||||||
},
|
},
|
||||||
|
@ -257,6 +261,7 @@ async function start(omnibox) {
|
||||||
});
|
});
|
||||||
|
|
||||||
omnibox.addPrefixQueryEvent("!!", {
|
omnibox.addPrefixQueryEvent("!!", {
|
||||||
|
name: "crates.io",
|
||||||
onSearch: (query) => {
|
onSearch: (query) => {
|
||||||
return crateSearcher.search(query);
|
return crateSearcher.search(query);
|
||||||
},
|
},
|
||||||
|
@ -277,6 +282,7 @@ async function start(omnibox) {
|
||||||
|
|
||||||
const REDIRECT_URL = chrome.runtime.getURL("manage/redirect.html");
|
const REDIRECT_URL = chrome.runtime.getURL("manage/redirect.html");
|
||||||
omnibox.addPrefixQueryEvent("!!!", {
|
omnibox.addPrefixQueryEvent("!!!", {
|
||||||
|
name: "Repository",
|
||||||
onSearch: (query) => {
|
onSearch: (query) => {
|
||||||
return crateSearcher.search(query);
|
return crateSearcher.search(query);
|
||||||
},
|
},
|
||||||
|
@ -296,6 +302,7 @@ async function start(omnibox) {
|
||||||
});
|
});
|
||||||
|
|
||||||
omnibox.addPrefixQueryEvent("#", {
|
omnibox.addPrefixQueryEvent("#", {
|
||||||
|
name: "Attributes",
|
||||||
isDefaultSearch: () => {
|
isDefaultSearch: () => {
|
||||||
return defaultSearch.attributes;
|
return defaultSearch.attributes;
|
||||||
},
|
},
|
||||||
|
@ -313,6 +320,7 @@ async function start(omnibox) {
|
||||||
});
|
});
|
||||||
|
|
||||||
omnibox.addPrefixQueryEvent("?", {
|
omnibox.addPrefixQueryEvent("?", {
|
||||||
|
name: "Can I use",
|
||||||
onSearch: (query) => {
|
onSearch: (query) => {
|
||||||
return caniuseSearcher.search(query);
|
return caniuseSearcher.search(query);
|
||||||
},
|
},
|
||||||
|
@ -331,6 +339,7 @@ async function start(omnibox) {
|
||||||
});
|
});
|
||||||
|
|
||||||
omnibox.addRegexQueryEvent(/^`?e\d{2,4}`?$/i, {
|
omnibox.addRegexQueryEvent(/^`?e\d{2,4}`?$/i, {
|
||||||
|
name: "Error code",
|
||||||
onSearch: (query) => {
|
onSearch: (query) => {
|
||||||
query = query.replace("`", "");
|
query = query.replace("`", "");
|
||||||
let baseIndex = parseInt(query.slice(1).padEnd(4, '0'));
|
let baseIndex = parseInt(query.slice(1).padEnd(4, '0'));
|
||||||
|
@ -350,6 +359,7 @@ async function start(omnibox) {
|
||||||
});
|
});
|
||||||
|
|
||||||
omnibox.addPrefixQueryEvent("%", {
|
omnibox.addPrefixQueryEvent("%", {
|
||||||
|
name: "Books",
|
||||||
onSearch: (query) => {
|
onSearch: (query) => {
|
||||||
return bookSearcher.search(query);
|
return bookSearcher.search(query);
|
||||||
},
|
},
|
||||||
|
@ -370,6 +380,7 @@ async function start(omnibox) {
|
||||||
|
|
||||||
const LINT_URL = "https://rust-lang.github.io/rust-clippy/master/";
|
const LINT_URL = "https://rust-lang.github.io/rust-clippy/master/";
|
||||||
omnibox.addPrefixQueryEvent(">", {
|
omnibox.addPrefixQueryEvent(">", {
|
||||||
|
name: "Clippy lints",
|
||||||
onSearch: (query) => {
|
onSearch: (query) => {
|
||||||
return lintSearcher.search(query);
|
return lintSearcher.search(query);
|
||||||
},
|
},
|
||||||
|
@ -382,13 +393,12 @@ async function start(omnibox) {
|
||||||
});
|
});
|
||||||
|
|
||||||
omnibox.addPrefixQueryEvent(":", {
|
omnibox.addPrefixQueryEvent(":", {
|
||||||
|
name: "Commands",
|
||||||
onSearch: async (query) => {
|
onSearch: async (query) => {
|
||||||
return commandManager.execute(query);
|
return commandManager.execute(query);
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
omnibox.addNoCacheQueries("/", "!", "@", ":");
|
|
||||||
|
|
||||||
if (!omnibox.extensionMode) return;
|
if (!omnibox.extensionMode) return;
|
||||||
|
|
||||||
chrome.storage.onChanged.addListener(changes => {
|
chrome.storage.onChanged.addListener(changes => {
|
||||||
|
|
Loading…
Reference in a new issue