mirror of
https://github.com/NotAShelf/neovim-flake.git
synced 2024-12-19 06:29:47 +01:00
Merge pull request #493 from NotAShelf/docs-search-bar
docs: add search widget to options page
This commit is contained in:
commit
d6cb4e0973
7 changed files with 119 additions and 21 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
|
||||||
|
|
7
.github/README.md
vendored
7
.github/README.md
vendored
|
@ -69,7 +69,7 @@
|
||||||
[Home-Manager module]: https://notashelf.github.io/nvf/index.xhtml#ch-standalone-hm
|
[Home-Manager module]: https://notashelf.github.io/nvf/index.xhtml#ch-standalone-hm
|
||||||
|
|
||||||
- **Simple**: One language to rule them all! Use Nix to configure everything,
|
- **Simple**: One language to rule them all! Use Nix to configure everything,
|
||||||
with additional Lua Support
|
with optional Lua support for robust configurability!
|
||||||
- **Reproducible**: Your configuration will behave the same _anywhere_. No
|
- **Reproducible**: Your configuration will behave the same _anywhere_. No
|
||||||
surprises, promise!
|
surprises, promise!
|
||||||
- **Portable**: nvf depends _solely_ on your Nix store, and nothing else. No
|
- **Portable**: nvf depends _solely_ on your Nix store, and nothing else. No
|
||||||
|
@ -77,8 +77,9 @@
|
||||||
- Options to install [standalone], [NixOS module] or [Home-Manager module].
|
- Options to install [standalone], [NixOS module] or [Home-Manager module].
|
||||||
- **Customizable**: There are _almost no defaults_ to annoy you. nvf is fully
|
- **Customizable**: There are _almost no defaults_ to annoy you. nvf is fully
|
||||||
customizable through the Nix module system.
|
customizable through the Nix module system.
|
||||||
- Not comfortable with a full-nix config or want to bring your Lua config? You
|
- Not comfortable with a full-nix config or want to bring your Lua config? You
|
||||||
can do just that, no unnecessary restrictions.
|
can do just that, no unnecessary restrictions.
|
||||||
|
- Lazyloading? We got it! Lazyload both internal and external plugins at will.
|
||||||
- **Well-documented**: Documentation is priority. You will _never_ face
|
- **Well-documented**: Documentation is priority. You will _never_ face
|
||||||
undocumented, obscure behaviour.
|
undocumented, obscure behaviour.
|
||||||
- **Idiomatic**: nvf does things ✨ _the right way_ ✨ - the codebase is, and
|
- **Idiomatic**: nvf does things ✨ _the right way_ ✨ - the codebase is, and
|
||||||
|
|
|
@ -62,7 +62,8 @@ in
|
||||||
# Copy anchor scripts to the script directory in document root.
|
# Copy anchor scripts to the script directory in document root.
|
||||||
cp -vt "$dest"/script \
|
cp -vt "$dest"/script \
|
||||||
${./static/script}/anchor-min.js \
|
${./static/script}/anchor-min.js \
|
||||||
${./static/script}/anchor-use.js
|
${./static/script}/anchor-use.js \
|
||||||
|
${./static/script}/search.js
|
||||||
|
|
||||||
substituteInPlace ./options.md \
|
substituteInPlace ./options.md \
|
||||||
--subst-var-by OPTIONS_JSON ./config-options.json
|
--subst-var-by OPTIONS_JSON ./config-options.json
|
||||||
|
@ -100,6 +101,7 @@ in
|
||||||
--script highlightjs/loader.js \
|
--script highlightjs/loader.js \
|
||||||
--script script/anchor-use.js \
|
--script script/anchor-use.js \
|
||||||
--script script/anchor-min.js \
|
--script script/anchor-min.js \
|
||||||
|
--script script/search.js \
|
||||||
--toc-depth 2 \
|
--toc-depth 2 \
|
||||||
--section-toc-depth 1 \
|
--section-toc-depth 1 \
|
||||||
manual.md \
|
manual.md \
|
||||||
|
|
|
@ -6,3 +6,5 @@
|
||||||
|
|
||||||
- Add [typst-preview.nvim] under
|
- Add [typst-preview.nvim] under
|
||||||
`languages.typst.extensions.typst-preview-nvim`.
|
`languages.typst.extensions.typst-preview-nvim`.
|
||||||
|
|
||||||
|
- Add a search widget to the options page in the nvf manual.
|
||||||
|
|
58
docs/static/script/search.js
vendored
Normal file
58
docs/static/script/search.js
vendored
Normal file
|
@ -0,0 +1,58 @@
|
||||||
|
document.addEventListener("DOMContentLoaded", () => {
|
||||||
|
if (!window.location.pathname.endsWith("options.html")) return;
|
||||||
|
|
||||||
|
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>
|
||||||
|
`;
|
||||||
|
document.body.prepend(searchDiv);
|
||||||
|
|
||||||
|
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("Something went wrong, page may be loaded incorrectly.");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
const dtElementsData = dtElements.map((dt, index) => ({
|
||||||
|
element: dt,
|
||||||
|
id: dtOptionIds[index],
|
||||||
|
ddElement: ddElements[index],
|
||||||
|
}));
|
||||||
|
|
||||||
|
const hiddenClass = "hidden";
|
||||||
|
const hiddenStyle = document.createElement("style");
|
||||||
|
hiddenStyle.innerHTML = `.${hiddenClass} { display: none; }`;
|
||||||
|
document.head.appendChild(hiddenStyle);
|
||||||
|
|
||||||
|
let debounceTimeout;
|
||||||
|
document.getElementById("search-input").addEventListener("input", (event) => {
|
||||||
|
clearTimeout(debounceTimeout);
|
||||||
|
debounceTimeout = setTimeout(() => {
|
||||||
|
const query = event.target.value.toLowerCase();
|
||||||
|
|
||||||
|
const matches = [];
|
||||||
|
const nonMatches = [];
|
||||||
|
|
||||||
|
dtElementsData.forEach(({ element, id, ddElement }) => {
|
||||||
|
const isMatch = id.includes(query);
|
||||||
|
if (isMatch) {
|
||||||
|
matches.push(element, ddElement);
|
||||||
|
} else {
|
||||||
|
nonMatches.push(element, ddElement);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
requestAnimationFrame(() => {
|
||||||
|
matches.forEach((el) => el?.classList.remove(hiddenClass));
|
||||||
|
nonMatches.forEach((el) => el?.classList.add(hiddenClass));
|
||||||
|
});
|
||||||
|
}, 200);
|
||||||
|
});
|
||||||
|
});
|
35
docs/static/style.scss
vendored
35
docs/static/style.scss
vendored
|
@ -189,14 +189,16 @@ th {
|
||||||
|
|
||||||
dt {
|
dt {
|
||||||
margin: 1.2rem 0 0.8rem;
|
margin: 1.2rem 0 0.8rem;
|
||||||
|
content-visibility: auto;
|
||||||
|
contain-intrinsic-size: auto 42px;
|
||||||
}
|
}
|
||||||
|
|
||||||
dd {
|
dd {
|
||||||
margin-left: 2rem;
|
margin-left: 2rem;
|
||||||
|
content-visibility: auto;
|
||||||
|
contain-intrinsic-size: auto 500px;
|
||||||
}
|
}
|
||||||
|
|
||||||
div.book {
|
div.book {}
|
||||||
}
|
|
||||||
|
|
||||||
ul {
|
ul {
|
||||||
@include margined;
|
@include margined;
|
||||||
|
@ -233,6 +235,33 @@ li {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#search-bar {
|
||||||
|
position: sticky;
|
||||||
|
top: 0;
|
||||||
|
background: white;
|
||||||
|
padding: 10px;
|
||||||
|
border-bottom: 1px solid $color-gray-200;
|
||||||
|
z-index: 1000;
|
||||||
|
@media (prefers-color-scheme: dark) {
|
||||||
|
background: $color-gray-900;
|
||||||
|
color: $color-gray-50;
|
||||||
|
border-bottom: 1px solid black;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#search-input {
|
||||||
|
width: 100%;
|
||||||
|
padding: 8px;
|
||||||
|
border: 1px solid #ccc;
|
||||||
|
border-radius: 4px;
|
||||||
|
background: inherit;
|
||||||
|
color: inherit;
|
||||||
|
}
|
||||||
|
|
||||||
|
.hidden {
|
||||||
|
display: none;
|
||||||
|
}
|
||||||
|
|
||||||
div.titlepage {
|
div.titlepage {
|
||||||
margin: 40px 0;
|
margin: 40px 0;
|
||||||
|
|
||||||
|
|
|
@ -12,22 +12,28 @@
|
||||||
cfg = config.vim;
|
cfg = config.vim;
|
||||||
in {
|
in {
|
||||||
options.vim = {
|
options.vim = {
|
||||||
enableLuaLoader = mkEnableOption ''
|
enableLuaLoader = mkOption {
|
||||||
[{option}`official documentation`]: https://neovim.io/doc/user/lua.html#vim.loader.enable()
|
type = bool;
|
||||||
|
default = false;
|
||||||
|
example = true;
|
||||||
|
description = ''
|
||||||
|
[{option}`official documentation`]: https://neovim.io/doc/user/lua.html#vim.loader.enable()
|
||||||
|
|
||||||
the experimental Lua module loader to speed up the start up process
|
the experimental Lua module loader to speed up the start up process
|
||||||
|
|
||||||
If `true`, this will enable the experimental Lua module loader which:
|
If `true`, this will enable the experimental Lua module loader which:
|
||||||
- overrides loadfile
|
- overrides loadfile
|
||||||
- adds the lua loader using the byte-compilation cache
|
- adds the lua loader using the byte-compilation cache
|
||||||
- adds the libs loader
|
- adds the libs loader
|
||||||
- removes the default Neovim loader
|
- removes the default Neovim loader
|
||||||
|
|
||||||
::: {.note}
|
::: {.note}
|
||||||
This is disabled by default. Before setting this option, please
|
The Lua module loader is *disabled* by default. Before setting this option, please
|
||||||
take a look at the [{option}`official documentation`].
|
take a look at the [{option}`official documentation`]. This option may be enabled by
|
||||||
:::
|
default in the future.
|
||||||
'';
|
:::
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
|
||||||
additionalRuntimePaths = mkOption {
|
additionalRuntimePaths = mkOption {
|
||||||
type = listOf (either path str);
|
type = listOf (either path str);
|
||||||
|
|
Loading…
Reference in a new issue