plugins/none-ls: refactor mkRaw

- Allow passing raw types through mkRaw
- Throw an error when passing invalid input into mkRaw
This commit is contained in:
Matt Sturgeon 2024-06-16 22:52:14 +01:00
parent 6ac0d2869d
commit 69e43a6bf9
No known key found for this signature in database
GPG key ID: 4F91844CED1A8299
2 changed files with 16 additions and 3 deletions

View file

@ -1,4 +1,8 @@
{ lib, _nixvimTests }:
{
lib,
nixvimTypes,
_nixvimTests,
}:
with lib;
{
listToUnkeyedAttrs =
@ -98,7 +102,16 @@ with lib;
ifNonNull' = x: y: if (x == null) then null else y;
mkRaw = r: if (isString r && (r != "")) then { __raw = r; } else null;
mkRaw =
r:
if r == null || r == "" then
null
else if isString r then
{ __raw = r; }
else if nixvimTypes.isRawType r then
r
else
throw "mkRaw: invalid input: ${generators.toPretty { multiline = false; } r}";
wrapDo = string: ''
do