mirror of
https://github.com/NotAShelf/neovim-flake.git
synced 2025-01-10 08:49:48 +01:00
Compare commits
3 commits
9a5bb57f03
...
79cc27a919
Author | SHA1 | Date | |
---|---|---|---|
79cc27a919 | |||
48bcd5d695 | |||
37dc96575d |
3 changed files with 36 additions and 34 deletions
|
@ -14,7 +14,7 @@ indent_style = space
|
|||
indent_size = 2
|
||||
trim_trailing_whitespace = false
|
||||
|
||||
[*.{nix,yml,yaml}]
|
||||
[*.{js,nix,yml,yaml}]
|
||||
indent_style = space
|
||||
indent_size = 2
|
||||
tab_width = 2
|
||||
|
|
65
docs/static/script/search.js
vendored
65
docs/static/script/search.js
vendored
|
@ -1,39 +1,40 @@
|
|||
document.addEventListener("DOMContentLoaded", () => {
|
||||
// The search widget should only be visible if we're in the options page. Else, we
|
||||
// want it hidden.
|
||||
if (window.location.pathname.endsWith("options.html")) {
|
||||
const searchBar = document.createElement("div");
|
||||
searchBar.id = "search-bar";
|
||||
searchBar.innerHTML = `
|
||||
<input type="text" id="search-input" placeholder="Search options by ID..." />
|
||||
<div id="search-results"></div>
|
||||
`;
|
||||
if (!window.location.pathname.endsWith("options.html")) return;
|
||||
|
||||
document.body.prepend(searchBar);
|
||||
const searchBar = document.createDocumentFragment();
|
||||
const searchDiv = document.createElement("div");
|
||||
searchDiv.id = "search-bar";
|
||||
searchDiv.innerHTML = `
|
||||
<input type="text" id="search-input" placeholder="Search options by ID..." />
|
||||
<div id="search-results"></div>
|
||||
`;
|
||||
searchBar.appendChild(searchDiv);
|
||||
document.body.prepend(searchDiv);
|
||||
|
||||
const dtElements = document.querySelectorAll("dt");
|
||||
const ddElements = document.querySelectorAll("dd");
|
||||
const dtElements = Array.from(document.querySelectorAll("dt"));
|
||||
const ddElements = Array.from(document.querySelectorAll("dd"));
|
||||
const dtOptionIds = dtElements.map(
|
||||
(dt) => dt.querySelector("a")?.id.toLowerCase() || "",
|
||||
);
|
||||
|
||||
if (dtElements.length === 0 || ddElements.length === 0) {
|
||||
console.warn(
|
||||
"No <dt> or <dd> elements found. Ensure your HTML contains the correct structure.",
|
||||
);
|
||||
}
|
||||
if (dtElements.length === 0 || ddElements.length === 0) {
|
||||
console.warn("Something went wrong, page may be loaded incorrectly.");
|
||||
return;
|
||||
}
|
||||
|
||||
// handle input and filter visible options
|
||||
document
|
||||
.getElementById("search-input")
|
||||
.addEventListener("input", (event) => {
|
||||
const query = event.target.value.toLowerCase();
|
||||
dtElements.forEach((dt, index) => {
|
||||
const optionId =
|
||||
dt.querySelector("a")?.id.toLowerCase() || "";
|
||||
const isMatch = optionId.includes(query);
|
||||
let debounceTimeout;
|
||||
document.getElementById("search-input").addEventListener("input", (event) => {
|
||||
clearTimeout(debounceTimeout);
|
||||
debounceTimeout = setTimeout(() => {
|
||||
const query = event.target.value.toLowerCase();
|
||||
dtElements.forEach((dt, index) => {
|
||||
const isMatch = dtOptionIds[index].includes(query);
|
||||
|
||||
// toggle visibility based on the query match
|
||||
dt.classList.toggle("hidden", !isMatch);
|
||||
ddElements[index]?.classList.toggle("hidden", !isMatch);
|
||||
});
|
||||
});
|
||||
}
|
||||
if (dt.classList.contains("hidden") !== !isMatch) {
|
||||
dt.classList.toggle("hidden", !isMatch);
|
||||
ddElements[index]?.classList.toggle("hidden", !isMatch);
|
||||
}
|
||||
});
|
||||
}, 200);
|
||||
});
|
||||
});
|
||||
|
|
|
@ -6,6 +6,7 @@
|
|||
inherit (lib.modules) mkRenamedOptionModule;
|
||||
inherit (lib.options) mkOption mkEnableOption literalExpression;
|
||||
inherit (lib.types) int bool str nullOr either listOf attrsOf;
|
||||
inherit (lib.nvim.types) mkPluginSetupOption;
|
||||
|
||||
cfg = config.vim.visuals;
|
||||
in {
|
||||
|
@ -15,7 +16,7 @@ in {
|
|||
|
||||
options.vim.visuals.indent-blankline = {
|
||||
enable = mkEnableOption "indentation guides [indent-blankline]";
|
||||
setupOpts = {
|
||||
setupOpts = mkPluginSetupOption "indent-blankline" {
|
||||
debounce = mkOption {
|
||||
type = int;
|
||||
description = "Debounce time in milliseconds";
|
||||
|
|
Loading…
Reference in a new issue