mirror of
https://github.com/NotAShelf/neovim-flake.git
synced 2025-01-10 13:29:49 +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
|
indent_size = 2
|
||||||
trim_trailing_whitespace = false
|
trim_trailing_whitespace = false
|
||||||
|
|
||||||
[*.{nix,yml,yaml}]
|
[*.{js,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,39 +1,40 @@
|
||||||
document.addEventListener("DOMContentLoaded", () => {
|
document.addEventListener("DOMContentLoaded", () => {
|
||||||
// The search widget should only be visible if we're in the options page. Else, we
|
if (!window.location.pathname.endsWith("options.html")) return;
|
||||||
// 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>
|
|
||||||
`;
|
|
||||||
|
|
||||||
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 dtElements = Array.from(document.querySelectorAll("dt"));
|
||||||
const ddElements = document.querySelectorAll("dd");
|
const ddElements = Array.from(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(
|
console.warn("Something went wrong, page may be loaded incorrectly.");
|
||||||
"No <dt> or <dd> elements found. Ensure your HTML contains the correct structure.",
|
return;
|
||||||
);
|
}
|
||||||
}
|
|
||||||
|
|
||||||
// handle input and filter visible options
|
let debounceTimeout;
|
||||||
document
|
document.getElementById("search-input").addEventListener("input", (event) => {
|
||||||
.getElementById("search-input")
|
clearTimeout(debounceTimeout);
|
||||||
.addEventListener("input", (event) => {
|
debounceTimeout = setTimeout(() => {
|
||||||
const query = event.target.value.toLowerCase();
|
const query = event.target.value.toLowerCase();
|
||||||
dtElements.forEach((dt, index) => {
|
dtElements.forEach((dt, index) => {
|
||||||
const optionId =
|
const isMatch = dtOptionIds[index].includes(query);
|
||||||
dt.querySelector("a")?.id.toLowerCase() || "";
|
|
||||||
const isMatch = optionId.includes(query);
|
|
||||||
|
|
||||||
// toggle visibility based on the query match
|
if (dt.classList.contains("hidden") !== !isMatch) {
|
||||||
dt.classList.toggle("hidden", !isMatch);
|
dt.classList.toggle("hidden", !isMatch);
|
||||||
ddElements[index]?.classList.toggle("hidden", !isMatch);
|
ddElements[index]?.classList.toggle("hidden", !isMatch);
|
||||||
});
|
}
|
||||||
});
|
});
|
||||||
}
|
}, 200);
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
|
@ -6,6 +6,7 @@
|
||||||
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 {
|
||||||
|
@ -15,7 +16,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 = {
|
setupOpts = mkPluginSetupOption "indent-blankline" {
|
||||||
debounce = mkOption {
|
debounce = mkOption {
|
||||||
type = int;
|
type = int;
|
||||||
description = "Debounce time in milliseconds";
|
description = "Debounce time in milliseconds";
|
||||||
|
|
Loading…
Reference in a new issue