Update generated neovim config
This commit is contained in:
@ -0,0 +1,9 @@
|
||||
@defer (on viewport) {
|
||||
<calendar-cmp />
|
||||
} @placeholder (minimum 100ms) {
|
||||
<small-component />
|
||||
} @loading (after 100s; minimum 200ms){
|
||||
<loading-spinner />
|
||||
} @error {
|
||||
<error-message />
|
||||
}
|
||||
@ -0,0 +1,5 @@
|
||||
@for (item of items; track item.id) {
|
||||
<li>{{ item.name }}</li>
|
||||
} @empty {
|
||||
<p>No items</p>
|
||||
}
|
||||
@ -0,0 +1,15 @@
|
||||
@if (someCondition) {
|
||||
<p>someCondition is true</p>
|
||||
} @else {
|
||||
<p>someCondition is false</p>
|
||||
}
|
||||
|
||||
<div>
|
||||
@if (someOther) {
|
||||
<span>True</span>
|
||||
|
||||
@if (nestedCondition) {
|
||||
<span>Nested</span>
|
||||
}
|
||||
}
|
||||
</div>
|
||||
@ -0,0 +1,13 @@
|
||||
<div>
|
||||
@switch (obj.property) {
|
||||
@case (1) {
|
||||
<p>Case 1</p>
|
||||
}
|
||||
@case (2) {
|
||||
<p>Case 2</p>
|
||||
}
|
||||
@default {
|
||||
<p>Default</p>
|
||||
}
|
||||
}
|
||||
</div>
|
||||
@ -0,0 +1,70 @@
|
||||
local Runner = require("tests.indent.common").Runner
|
||||
local runner = Runner:new(it, "tests/indent/angular", {
|
||||
tabstop = 2,
|
||||
shiftwidth = 2,
|
||||
expandtab = true,
|
||||
filetype = "htmlangular",
|
||||
})
|
||||
|
||||
describe("indent HTML Angular:", function()
|
||||
describe("whole file:", function()
|
||||
runner:whole_file "."
|
||||
end)
|
||||
|
||||
describe("new line:", function()
|
||||
for _, info in ipairs {
|
||||
{ 1, 2 },
|
||||
{ 2, 2 },
|
||||
{ 3, 2 },
|
||||
{ 4, 2 },
|
||||
{ 6, 0 },
|
||||
{ 7, 2 },
|
||||
{ 8, 4 },
|
||||
{ 10, 4 },
|
||||
{ 11, 6 },
|
||||
{ 12, 6 },
|
||||
{ 13, 4 },
|
||||
{ 14, 2 },
|
||||
} do
|
||||
runner:new_line("if-else.html", { on_line = info[1], text = "//", indent = info[2] })
|
||||
end
|
||||
|
||||
for _, info in ipairs {
|
||||
{ 1, 2 },
|
||||
{ 2, 4 },
|
||||
{ 3, 6 },
|
||||
{ 4, 6 },
|
||||
{ 6, 6 },
|
||||
{ 7, 6 },
|
||||
{ 9, 6 },
|
||||
{ 10, 6 },
|
||||
{ 12, 2 },
|
||||
} do
|
||||
runner:new_line("switch-case.html", { on_line = info[1], text = "//", indent = info[2] })
|
||||
end
|
||||
|
||||
for _, info in ipairs {
|
||||
{ 1, 2 },
|
||||
{ 2, 2 },
|
||||
{ 3, 2 },
|
||||
{ 4, 2 },
|
||||
{ 5, 0 },
|
||||
} do
|
||||
runner:new_line("for.html", { on_line = info[1], text = "//", indent = info[2] })
|
||||
end
|
||||
|
||||
for _, info in ipairs {
|
||||
{ 1, 2 },
|
||||
{ 2, 2 },
|
||||
{ 3, 2 },
|
||||
{ 4, 2 },
|
||||
{ 5, 2 },
|
||||
{ 6, 2 },
|
||||
{ 7, 2 },
|
||||
{ 8, 2 },
|
||||
{ 9, 0 },
|
||||
} do
|
||||
runner:new_line("defer.html", { on_line = info[1], text = "//", indent = info[2] })
|
||||
end
|
||||
end)
|
||||
end)
|
||||
@ -0,0 +1,134 @@
|
||||
{ lib }:
|
||||
with lib.lists;
|
||||
with lib.types;
|
||||
with lib.attrsets;
|
||||
with lib.strings; {
|
||||
doubleFromSystem = { cpu, kernel, abi, ... }:
|
||||
if abi == abis.cygnus then
|
||||
"${cpu.name}-cygwin"
|
||||
else if kernel.families ? darwin then
|
||||
"${cpu.name}-darwin"
|
||||
else
|
||||
"${cpu.name}-${kernelName kernel}";
|
||||
|
||||
tripleFromSystem = { cpu, vendor, kernel, abi, ... }@sys:
|
||||
assert isSystem sys;
|
||||
let
|
||||
optExecFormat = lib.optionalString (kernel.name == "netbsd"
|
||||
&& gnuNetBSDDefaultExecFormat cpu != kernel.execFormat)
|
||||
kernel.execFormat.name;
|
||||
optAbi = lib.optionalString (abi != abis.unknown) "-${abi.name}";
|
||||
in "${cpu.name}-${vendor.name}-${
|
||||
kernelName kernel
|
||||
}${optExecFormat}${optAbi}";
|
||||
|
||||
mkSystemFromSkeleton = { cpu,
|
||||
# Optional, but fallback too complex for here.
|
||||
# Inferred below instead.
|
||||
vendor ? assert false; null, kernel,
|
||||
# Also inferred below
|
||||
abi ? assert false; null, }@args:
|
||||
let
|
||||
getCpu = name: cpuTypes.${name} or (throw "Unknown CPU type: ${name}");
|
||||
getVendor = name: vendors.${name} or (throw "Unknown vendor: ${name}");
|
||||
getKernel = name: kernels.${name} or (throw "Unknown kernel: ${name}");
|
||||
getAbi = name: abis.${name} or (throw "Unknown ABI: ${name}");
|
||||
|
||||
parsed = {
|
||||
cpu = getCpu args.cpu;
|
||||
vendor = if args ? vendor then
|
||||
getVendor args.vendor
|
||||
else if isDarwin parsed then
|
||||
vendors.apple
|
||||
else if isWindows parsed then
|
||||
vendors.pc
|
||||
else
|
||||
vendors.unknown;
|
||||
kernel = if hasPrefix "darwin" args.kernel then
|
||||
getKernel "darwin"
|
||||
else if hasPrefix "netbsd" args.kernel then
|
||||
getKernel "netbsd"
|
||||
else
|
||||
getKernel args.kernel;
|
||||
abi = if args ? abi then
|
||||
getAbi args.abi
|
||||
else if isLinux parsed || isWindows parsed then
|
||||
if isAarch32 parsed then
|
||||
if lib.versionAtLeast (parsed.cpu.version or "0") "6" then
|
||||
abis.gnueabihf
|
||||
else
|
||||
abis.gnueabi
|
||||
else if isPower64 parsed && isBigEndian parsed then
|
||||
abis.gnuabielfv2
|
||||
else
|
||||
abis.gnu
|
||||
else
|
||||
abis.unknown;
|
||||
};
|
||||
in mkSystem parsed;
|
||||
|
||||
mkSkeletonFromList = l:
|
||||
{
|
||||
"1" = if elemAt l 0 == "avr" then {
|
||||
cpu = elemAt l 0;
|
||||
kernel = "none";
|
||||
abi = "unknown";
|
||||
} else
|
||||
throw "Target specification with 1 components is ambiguous";
|
||||
"2" = # We only do 2-part hacks for things Nix already supports
|
||||
if elemAt l 1 == "cygwin" then {
|
||||
cpu = elemAt l 0;
|
||||
kernel = "windows";
|
||||
abi = "cygnus";
|
||||
} else if elemAt l 1 == "windows" then {
|
||||
cpu = elemAt l 0;
|
||||
kernel = "windows";
|
||||
abi = "msvc";
|
||||
} else if (elemAt l 1) == "elf" then {
|
||||
cpu = elemAt l 0;
|
||||
vendor = "unknown";
|
||||
kernel = "none";
|
||||
abi = elemAt l 1;
|
||||
} else {
|
||||
cpu = elemAt l 0;
|
||||
kernel = elemAt l 1;
|
||||
};
|
||||
"3" =
|
||||
# cpu-kernel-environment
|
||||
if elemAt l 1 == "linux"
|
||||
|| elem (elemAt l 2) [ "eabi" "eabihf" "elf" "gnu" ] then {
|
||||
cpu = elemAt l 0;
|
||||
kernel = elemAt l 1;
|
||||
abi = elemAt l 2;
|
||||
vendor = "unknown";
|
||||
} else if elemAt l 1 == "apple"
|
||||
|| elem (elemAt l 2) [ "wasi" "redox" "mmixware" "ghcjs" "mingw32" ]
|
||||
|| hasPrefix "freebsd" (elemAt l 2) || hasPrefix "netbsd" (elemAt l 2)
|
||||
|| hasPrefix "genode" (elemAt l 2) then {
|
||||
cpu = elemAt l 0;
|
||||
vendor = elemAt l 1;
|
||||
kernel = if elemAt l 2 == "mingw32" then
|
||||
"windows" # autotools breaks on -gnu for window
|
||||
else
|
||||
elemAt l 2;
|
||||
} else
|
||||
throw "Target specification with 3 components is ambiguous";
|
||||
"4" = {
|
||||
cpu = elemAt l 0;
|
||||
vendor = elemAt l 1;
|
||||
kernel = elemAt l 2;
|
||||
abi = elemAt l 3;
|
||||
};
|
||||
}.${toString (length l)} or (throw
|
||||
"system string has invalid number of hyphen-separated components");
|
||||
|
||||
# GNU build systems assume that older NetBSD architectures are using a.out.
|
||||
gnuNetBSDDefaultExecFormat = cpu:
|
||||
if (cpu.family == "arm" && cpu.bits == 32)
|
||||
|| (cpu.family == "sparc" && cpu.bits == 32)
|
||||
|| (cpu.family == "m68k" && cpu.bits == 32)
|
||||
|| (cpu.family == "x86" && cpu.bits == 32) then
|
||||
execFormats.aout
|
||||
else
|
||||
execFormats.elf;
|
||||
}
|
||||
@ -0,0 +1,130 @@
|
||||
{ lib }:
|
||||
with lib.lists;
|
||||
with lib.types;
|
||||
with lib.attrsets;
|
||||
with lib.strings;
|
||||
with (import ./inspect.nix { inherit lib; }).predicates;
|
||||
|
||||
let
|
||||
inherit (lib.options) mergeOneOption;
|
||||
|
||||
setTypes = type:
|
||||
mapAttrs (name: value:
|
||||
assert type.check value;
|
||||
setType type.name ({ inherit name; } // value));
|
||||
|
||||
in rec {
|
||||
|
||||
################################################################################
|
||||
|
||||
types.openSignificantByte = mkOptionType {
|
||||
name = "significant-byte";
|
||||
description = "Endianness";
|
||||
merge = mergeOneOption;
|
||||
};
|
||||
|
||||
types.significantByte = enum (attrValues significantBytes);
|
||||
|
||||
significantBytes = setTypes types.openSignificantByte {
|
||||
bigEndian = { };
|
||||
littleEndian = { };
|
||||
};
|
||||
|
||||
################################################################################
|
||||
|
||||
# Reasonable power of 2
|
||||
types.bitWidth = enum [ 8 16 32 64 128 ];
|
||||
|
||||
################################################################################
|
||||
|
||||
types.openCpuType = mkOptionType {
|
||||
name = "cpu-type";
|
||||
description = "instruction set architecture name and information";
|
||||
merge = mergeOneOption;
|
||||
check = x:
|
||||
types.bitWidth.check x.bits && (if 8 < x.bits then
|
||||
types.significantByte.check x.significantByte
|
||||
else
|
||||
!(x ? significantByte));
|
||||
};
|
||||
|
||||
types.cpuType = enum (attrValues cpuTypes);
|
||||
|
||||
cpuTypes = with significantBytes;
|
||||
setTypes types.openCpuType {
|
||||
arm = {
|
||||
bits = 32;
|
||||
significantByte = littleEndian;
|
||||
family = "arm";
|
||||
};
|
||||
armv5tel = {
|
||||
bits = 32;
|
||||
significantByte = littleEndian;
|
||||
family = "arm";
|
||||
version = "5";
|
||||
arch = "armv5t";
|
||||
};
|
||||
};
|
||||
|
||||
isCompatible = a: b:
|
||||
with cpuTypes;
|
||||
lib.any lib.id [
|
||||
# x86
|
||||
(b == i386 && isCompatible a i486)
|
||||
(b == i486 && isCompatible a i586)
|
||||
(b == i586 && isCompatible a i686)
|
||||
|
||||
# ARMv6
|
||||
(b == armv6l && isCompatible a armv6m)
|
||||
(b == armv6m && isCompatible a armv7l)
|
||||
];
|
||||
|
||||
################################################################################
|
||||
|
||||
types.openVendor = mkOptionType {
|
||||
name = "vendor";
|
||||
description = "vendor for the platform";
|
||||
merge = mergeOneOption;
|
||||
};
|
||||
|
||||
abis = setTypes types.openAbi {
|
||||
cygnus = { };
|
||||
msvc = { };
|
||||
|
||||
# Other architectures should use ELF in embedded situations.
|
||||
elf = { };
|
||||
|
||||
androideabi = { };
|
||||
android = {
|
||||
assertions = [{
|
||||
assertion = platform: !platform.isAarch32;
|
||||
message = ''
|
||||
The "android" ABI is not for 32-bit ARM. Use "androideabi" instead.
|
||||
'';
|
||||
}];
|
||||
};
|
||||
};
|
||||
|
||||
################################################################################
|
||||
|
||||
types.parsedPlatform = mkOptionType {
|
||||
name = "system";
|
||||
description =
|
||||
"fully parsed representation of llvm- or nix-style platform tuple";
|
||||
merge = mergeOneOption;
|
||||
check = { cpu, vendor, kernel, abi, }:
|
||||
types.cpuType.check cpu && types.vendor.check vendor
|
||||
&& types.kernel.check kernel && types.abi.check abi;
|
||||
};
|
||||
|
||||
isSystem = isType "system";
|
||||
|
||||
mkSystem = components:
|
||||
assert types.parsedPlatform.check components;
|
||||
setType "system" components;
|
||||
|
||||
mkSystemFromString = s:
|
||||
mkSystemFromSkeleton (mkSkeletonFromList (lib.splitString "-" s));
|
||||
|
||||
################################################################################
|
||||
}
|
||||
@ -0,0 +1,40 @@
|
||||
local Runner = require("tests.indent.common").Runner
|
||||
|
||||
local runner = Runner:new(it, "tests/indent/nix", {
|
||||
tabstop = 2,
|
||||
shiftwidth = 2,
|
||||
softtabstop = 2,
|
||||
expandtab = true,
|
||||
})
|
||||
|
||||
describe("indent Nix:", function()
|
||||
describe("whole file:", function()
|
||||
runner:whole_file(".", {
|
||||
expected_failures = {},
|
||||
})
|
||||
end)
|
||||
|
||||
describe("new line:", function()
|
||||
for _, info in ipairs {
|
||||
{ 14, 2 },
|
||||
{ 16, 2 },
|
||||
{ 48, 4 },
|
||||
{ 112, 6 },
|
||||
} do
|
||||
runner:new_line("general.nix", { on_line = info[1], text = "x = 1;", indent = info[2] })
|
||||
end
|
||||
|
||||
for _, info in ipairs {
|
||||
{ 115, 6 },
|
||||
{ 113, 10 },
|
||||
{ 6, 4 },
|
||||
{ 12, 2 },
|
||||
{ 16, 6 },
|
||||
{ 35, 6 },
|
||||
{ 23, 2 },
|
||||
{ 21, 6 },
|
||||
} do
|
||||
runner:new_line("conds.nix", { on_line = info[1], text = "x = 1;", indent = info[2] })
|
||||
end
|
||||
end)
|
||||
end)
|
||||
@ -0,0 +1,12 @@
|
||||
<?php
|
||||
enum DaysOfWeek: int
|
||||
{
|
||||
case Sunday = 0;
|
||||
case Monday = 1;
|
||||
}
|
||||
|
||||
class Foo {
|
||||
public int $id;
|
||||
public string $brand;
|
||||
}
|
||||
?>
|
||||
@ -0,0 +1,35 @@
|
||||
if (
|
||||
True
|
||||
or 1
|
||||
or False
|
||||
):
|
||||
pass
|
||||
|
||||
if (
|
||||
True
|
||||
or 1
|
||||
or False):
|
||||
pass
|
||||
|
||||
if (True
|
||||
or 1
|
||||
or False):
|
||||
pass
|
||||
|
||||
while (
|
||||
False
|
||||
or 1
|
||||
or False
|
||||
):
|
||||
pass
|
||||
|
||||
while (
|
||||
False
|
||||
or 1
|
||||
or False):
|
||||
pass
|
||||
|
||||
while (False
|
||||
or 1
|
||||
or False):
|
||||
pass
|
||||
@ -0,0 +1,2 @@
|
||||
mtcars %>%
|
||||
head() %>%
|
||||
@ -0,0 +1,23 @@
|
||||
@genType
|
||||
type person = {
|
||||
name: string,
|
||||
age: int,
|
||||
}
|
||||
|
||||
@genType
|
||||
type renderMe<'a> = React.component<{
|
||||
"randomString": string,
|
||||
"poly": 'a,
|
||||
}>
|
||||
|
||||
@genType.import("./hookExample") @react.component
|
||||
external make: (
|
||||
~person: person,
|
||||
~children: React.element,
|
||||
~renderMe: renderMe<'a>,
|
||||
) => React.element = "makeRenamed"
|
||||
|
||||
@genType.import("./hookExample")
|
||||
external foo: (~person: person) => string = "foo"
|
||||
|
||||
let hi = 'a'
|
||||
@ -0,0 +1,151 @@
|
||||
let hit = ({hit, children}: DocSearch.hitComponent) => {
|
||||
let toTitle = str =>
|
||||
str->Js.String2.charAt(0)->Js.String2.toUpperCase ++ Js.String2.sliceToEnd(str, ~from=1)
|
||||
|
||||
let description = switch hit.url
|
||||
->Js.String2.split("/")
|
||||
->Js.Array2.sliceFrom(1)
|
||||
->Belt.List.fromArray {
|
||||
| list{"blog" as r | "community" as r, ..._} => r->toTitle
|
||||
| list{"docs", doc, version, ...rest} =>
|
||||
let path = rest->Belt.List.toArray
|
||||
|
||||
let info =
|
||||
path
|
||||
->Js.Array2.slice(~start=0, ~end_=Js.Array2.length(path) - 1)
|
||||
->Js.Array2.map(path =>
|
||||
switch path {
|
||||
| "api" => "API"
|
||||
| other => toTitle(other)
|
||||
}
|
||||
)
|
||||
|
||||
[doc->toTitle, version->toTitle]->Js.Array2.concat(info)->Js.Array2.joinWith(" / ")
|
||||
| _ => ""
|
||||
}
|
||||
|
||||
<Next.Link href={hit.url} className="flex flex-col w-full">
|
||||
<span className="text-gray-60 captions px-4 pt-3 pb-1 block">
|
||||
{description->React.string}
|
||||
</span>
|
||||
children
|
||||
</Next.Link>
|
||||
}
|
||||
|
||||
let transformItems = (items: DocSearch.transformItems) => {
|
||||
items->Belt.Array.keepMap(item => {
|
||||
let url = try Webapi.URL.make(item.url)->Some catch {
|
||||
| Js.Exn.Error(obj) =>
|
||||
Js.Console.error2(`Failed to parse URL ${item.url}`, obj)
|
||||
None
|
||||
}
|
||||
switch url {
|
||||
| Some({pathname, hash}) => {...item, url: pathname ++ hash}->Some
|
||||
| None => None
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
@react.component
|
||||
let make = () => {
|
||||
let (state, setState) = React.useState(_ => Inactive)
|
||||
let router = Next.Router.useRouter()
|
||||
|
||||
let version = switch Url.parse(router.route).version {
|
||||
| Version(v) => v
|
||||
| _ => "latest"
|
||||
}
|
||||
|
||||
let handleCloseModal = () => {
|
||||
let () = switch ReactDOM.querySelector(".DocSearch-Modal") {
|
||||
| Some(modal) =>
|
||||
switch ReactDOM.querySelector("body") {
|
||||
| Some(body) =>
|
||||
open Webapi
|
||||
body->Element.classList->ClassList.remove("DocSearch--active")
|
||||
modal->Element.addEventListener("transitionend", () => {
|
||||
setState(_ => Inactive)
|
||||
})
|
||||
| None => setState(_ => Inactive)
|
||||
}
|
||||
| None => ()
|
||||
}
|
||||
}
|
||||
|
||||
React.useEffect(() => {
|
||||
let isEditableTag = el =>
|
||||
switch el->tagName {
|
||||
| "TEXTAREA" | "SELECT" | "INPUT" => true
|
||||
| _ => false
|
||||
}
|
||||
|
||||
let focusSearch = e => {
|
||||
switch activeElement {
|
||||
| Some(el) if el->isEditableTag || el->isContentEditable => ()
|
||||
| _ =>
|
||||
setState(_ => Active)
|
||||
e->keyboardEventPreventDefault
|
||||
}
|
||||
}
|
||||
|
||||
let handleGlobalKeyDown = e => {
|
||||
switch e.key {
|
||||
| "/" => focusSearch(e)
|
||||
| "k" if e.ctrlKey || e.metaKey => focusSearch(e)
|
||||
| "Escape" => handleCloseModal()
|
||||
| _ => ()
|
||||
}
|
||||
}
|
||||
addKeyboardEventListener("keydown", handleGlobalKeyDown)
|
||||
Some(() => removeKeyboardEventListener("keydown", handleGlobalKeyDown))
|
||||
}, [setState])
|
||||
|
||||
let onClick = _ => {
|
||||
setState(_ => Active)
|
||||
}
|
||||
|
||||
let onClose = React.useCallback(() => {
|
||||
handleCloseModal()
|
||||
}, [setState])
|
||||
|
||||
<>
|
||||
<button onClick type_="button" className="text-gray-60 hover:text-fire-50 p-2">
|
||||
<Icon.MagnifierGlass className="fill-current" />
|
||||
</button>
|
||||
{switch state {
|
||||
| Active =>
|
||||
switch ReactDOM.querySelector("body") {
|
||||
| Some(element) =>
|
||||
ReactDOM.createPortal(
|
||||
<DocSearch
|
||||
apiKey
|
||||
appId
|
||||
indexName
|
||||
onClose
|
||||
searchParameters={facetFilters: ["version:" ++ version]}
|
||||
initialScrollY={window->scrollY}
|
||||
transformItems={transformItems}
|
||||
hitComponent=hit
|
||||
/>
|
||||
element,
|
||||
)
|
||||
| None => React.null
|
||||
}
|
||||
| Inactive => React.null
|
||||
}}
|
||||
</>
|
||||
}
|
||||
|
||||
let comparable = (type key, ~cmp) => {
|
||||
module N = MakeComparable({
|
||||
type t = key
|
||||
let cmp = cmp
|
||||
})
|
||||
module(N: Comparable with type t = key)
|
||||
}
|
||||
|
||||
<Next.Link href={hit.url} className="flex flex-col w-full">
|
||||
<span className="text-gray-60 captions px-4 pt-3 pb-1 block">
|
||||
{description->React.string}
|
||||
children
|
||||
</Next.Link>
|
||||
@ -0,0 +1,104 @@
|
||||
include UseClient
|
||||
include UseQuery
|
||||
include UseMutation
|
||||
include UseSubscription
|
||||
|
||||
type hookResponse<'ret> = Types.Hooks.hookResponse<'ret> = {
|
||||
operation: Types.operation,
|
||||
fetching: bool,
|
||||
data: option<'ret>,
|
||||
error: option<CombinedError.t>,
|
||||
response: Types.Hooks.response<'ret>,
|
||||
extensions: option<Js.Json.t>,
|
||||
stale: bool,
|
||||
}
|
||||
|
||||
Js.Array2.slice(~start=0, ~end_=Js.Array2.length(moduleRoute) - 1)
|
||||
|
||||
let pathModule = Path.join([dir, version, `${moduleName}.json`])
|
||||
|
||||
let {Api.LocMsg.row: row, column, shortMsg} = locMsg
|
||||
|
||||
let message = `${"error"->red}: failed to compile examples from ${kind} ${test.id->cyan}\n${errorMessage}`
|
||||
|
||||
let version = (evt->ReactEvent.Form.target)["value"]
|
||||
|
||||
let rehypePlugins =
|
||||
[Rehype.WithOptions([Plugin(Rehype.slug), SlugOption({prefix: slugPrefix ++ "-"})])]->Some
|
||||
|
||||
module Item = {
|
||||
type t = {
|
||||
name: string,
|
||||
sellIn: int,
|
||||
quality: int,
|
||||
}
|
||||
|
||||
let make = (~name, ~sellIn, ~quality): t => {
|
||||
name,
|
||||
sellIn,
|
||||
quality,
|
||||
}
|
||||
}
|
||||
|
||||
let updateQuality = (items: array<Item.t>) => {
|
||||
items->Js.Array2.map(item => {
|
||||
let newItem = ref(item)
|
||||
|
||||
call(
|
||||
asdf,
|
||||
asdf
|
||||
)
|
||||
|
||||
if (
|
||||
newItem.contents.name != "Aged Brie" && 5 > 2 &&
|
||||
newItem.contents.name != "Backstage passes to a TAFKAL80ETC concert"
|
||||
) {
|
||||
if newItem.contents.quality > 0 {
|
||||
if newItem.contents.name != "Sulfuras, Hand of Ragnaros" {
|
||||
newItem := {...newItem.contents, quality: newItem.contents.quality - 1}
|
||||
}
|
||||
}
|
||||
} else if newItem.contents.quality < 50 {
|
||||
newItem := {...newItem.contents, quality: newItem.contents.quality + 1}
|
||||
|
||||
if newItem.contents.name == "Backstage passes to a TAFKAL80ETC concert" {
|
||||
if newItem.contents.sellIn < 11 {
|
||||
if newItem.contents.quality < 50 {
|
||||
newItem := {...newItem.contents, quality: newItem.contents.quality + 1}
|
||||
}
|
||||
}
|
||||
|
||||
if newItem.contents.sellIn < 6 {
|
||||
if newItem.contents.quality < 50 {
|
||||
newItem := {...newItem.contents, quality: newItem.contents.quality + 1}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if newItem.contents.name != "Sulfuras, Hand of Ragnaros" {
|
||||
newItem := {...newItem.contents, sellIn: newItem.contents.sellIn - 1}
|
||||
}
|
||||
|
||||
if newItem.contents.sellIn < 0 {
|
||||
if newItem.contents.name != "Aged Brie" {
|
||||
if newItem.contents.name != "Backstage passes to a TAFKAL80ETC concert" {
|
||||
if newItem.contents.quality > 0 {
|
||||
if newItem.contents.name != "Sulfuras, Hand of Ragnaros" {
|
||||
newItem := {...newItem.contents, quality: newItem.contents.quality - 1}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
newItem := {
|
||||
...newItem.contents,
|
||||
quality: newItem.contents.quality - newItem.contents.quality,
|
||||
}
|
||||
}
|
||||
} else if newItem.contents.quality < 50 {
|
||||
newItem := {...newItem.contents, quality: newItem.contents.quality + 1}
|
||||
}
|
||||
}
|
||||
|
||||
newItem.contents
|
||||
})
|
||||
}
|
||||
@ -0,0 +1,33 @@
|
||||
local Runner = require("tests.indent.common").Runner
|
||||
|
||||
local run = Runner:new(it, "tests/indent/rescript", {
|
||||
tabstop = 2,
|
||||
shiftwidth = 2,
|
||||
softtabstop = 0,
|
||||
expandtab = true,
|
||||
})
|
||||
|
||||
describe("indent ReScript:", function()
|
||||
describe("whole file:", function()
|
||||
run:whole_file(".", {})
|
||||
end)
|
||||
|
||||
describe("new line:", function()
|
||||
run:new_line("basic.res", { on_line = 5, text = "x", indent = 0 })
|
||||
run:new_line("basic.res", { on_line = 9, text = '"another": here,', indent = 2 })
|
||||
run:new_line("basic.res", { on_line = 10, text = "}", indent = 0 })
|
||||
run:new_line("basic.res", { on_line = 14, text = "~test: test,", indent = 2 })
|
||||
run:new_line("basic.res", { on_line = 18, text = "x", indent = 0 })
|
||||
|
||||
run:new_line("complex.res", { on_line = 3, text = "x", indent = 2 })
|
||||
run:new_line("complex.res", { on_line = 5, text = "x", indent = 4 })
|
||||
run:new_line("complex.res", { on_line = 17, text = "|", indent = 10 })
|
||||
run:new_line("complex.res", { on_line = 25, text = "x", indent = 2 })
|
||||
run:new_line("complex.res", { on_line = 60, text = "x", indent = 6 })
|
||||
run:new_line("complex.res", { on_line = 120, text = "x", indent = 14 })
|
||||
run:new_line("complex.res", { on_line = 136, text = "x", indent = 2 })
|
||||
|
||||
run:new_line("conditional.res", { on_line = 6, text = "test: bool,", indent = 2 })
|
||||
run:new_line("conditional.res", { on_line = 95, text = "x", indent = 10 })
|
||||
end)
|
||||
end)
|
||||
@ -0,0 +1,27 @@
|
||||
; vim: ft=query
|
||||
; format-ignore
|
||||
(((symbol) @constant
|
||||
(#not-lua-match? @constant "^_*[A-Z][A-Z0-9_]*$"))
|
||||
; ^ @luap
|
||||
)
|
||||
|
||||
; format-ignore
|
||||
(((tag
|
||||
(attributes
|
||||
(attribute
|
||||
(attribute_name) @keyword)))
|
||||
(#match? @keyword "^(:|v-bind|v-|\\@)"))
|
||||
; ^ @regex
|
||||
)
|
||||
|
||||
((comment) @injection.language
|
||||
.
|
||||
[
|
||||
(string_expression
|
||||
(string_fragment) @injection.content)
|
||||
(indented_string_expression
|
||||
(string_fragment) @injection.content)
|
||||
]
|
||||
(#gsub! @injection.language "#%s*([%w%p]+)%s*" "%1")
|
||||
; ^ @luap
|
||||
(#set! injection.combined))
|
||||
Reference in New Issue
Block a user