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