mirror of
https://github.com/NotAShelf/nvf.git
synced 2024-11-26 15:06:45 +00:00
Merge pull request #289 from horriblename/lua-include-empty-attrs
lib: do not filter out empty attrs in toLuaObject
This commit is contained in:
commit
2c9a9b4d29
3 changed files with 9 additions and 12 deletions
|
@ -19,6 +19,8 @@ Release notes for release 0.7
|
||||||
[horriblename](https://github.com/horriblename):
|
[horriblename](https://github.com/horriblename):
|
||||||
|
|
||||||
- Fix broken treesitter-context keybinds in visual mode
|
- Fix broken treesitter-context keybinds in visual mode
|
||||||
|
- Depcrecate use of `__empty` to define empty tables in lua. Empty attrset are
|
||||||
|
no longer filtered and thus should be used instead.
|
||||||
|
|
||||||
[NotAShelf](https://github.com/notashelf)
|
[NotAShelf](https://github.com/notashelf)
|
||||||
|
|
||||||
|
|
12
lib/lua.nix
12
lib/lua.nix
|
@ -3,7 +3,7 @@
|
||||||
inherit (builtins) hasAttr head throw typeOf isList isAttrs isBool isInt isString isPath isFloat toJSON;
|
inherit (builtins) hasAttr head throw typeOf isList isAttrs isBool isInt isString isPath isFloat toJSON;
|
||||||
inherit (lib.attrsets) mapAttrsToList filterAttrs;
|
inherit (lib.attrsets) mapAttrsToList filterAttrs;
|
||||||
inherit (lib.strings) concatStringsSep concatMapStringsSep stringToCharacters;
|
inherit (lib.strings) concatStringsSep concatMapStringsSep stringToCharacters;
|
||||||
inherit (lib.trivial) boolToString;
|
inherit (lib.trivial) boolToString warn;
|
||||||
in rec {
|
in rec {
|
||||||
wrapLuaConfig = {
|
wrapLuaConfig = {
|
||||||
luaBefore ? "",
|
luaBefore ? "",
|
||||||
|
@ -66,7 +66,10 @@ in rec {
|
||||||
if isLuaInline args
|
if isLuaInline args
|
||||||
then args.expr
|
then args.expr
|
||||||
else if hasAttr "__empty" args
|
else if hasAttr "__empty" args
|
||||||
then "{ }"
|
then
|
||||||
|
warn ''
|
||||||
|
Using `__empty` to define an empty lua table is deprecated. Use an empty attrset instead.
|
||||||
|
'' "{ }"
|
||||||
else
|
else
|
||||||
"{"
|
"{"
|
||||||
+ (concatStringsSep ","
|
+ (concatStringsSep ","
|
||||||
|
@ -76,10 +79,7 @@ in rec {
|
||||||
then toLuaObject v
|
then toLuaObject v
|
||||||
else "[${toLuaObject n}] = " + (toLuaObject v))
|
else "[${toLuaObject n}] = " + (toLuaObject v))
|
||||||
(filterAttrs
|
(filterAttrs
|
||||||
(
|
(_: v: v != null)
|
||||||
_: v:
|
|
||||||
(v != null) && (toLuaObject v != "{}")
|
|
||||||
)
|
|
||||||
args)))
|
args)))
|
||||||
+ "}"
|
+ "}"
|
||||||
else if isList args
|
else if isList args
|
||||||
|
|
|
@ -60,16 +60,11 @@
|
||||||
config = (attrs) the configuration options for this mapping (noremap, silent...)
|
config = (attrs) the configuration options for this mapping (noremap, silent...)
|
||||||
}
|
}
|
||||||
*/
|
*/
|
||||||
normalizeAction = action: let
|
normalizeAction = action: {
|
||||||
# Extract the values of the config options that have been explicitly set by the user
|
# Extract the values of the config options that have been explicitly set by the user
|
||||||
config =
|
config =
|
||||||
filterAttrs (_: v: v != null)
|
filterAttrs (_: v: v != null)
|
||||||
(getAttrs (attrNames mapConfigOptions) action);
|
(getAttrs (attrNames mapConfigOptions) action);
|
||||||
in {
|
|
||||||
config =
|
|
||||||
if config == {}
|
|
||||||
then {"__empty" = null;}
|
|
||||||
else config;
|
|
||||||
action =
|
action =
|
||||||
if action.lua
|
if action.lua
|
||||||
then mkLuaInline action.action
|
then mkLuaInline action.action
|
||||||
|
|
Loading…
Reference in a new issue