-
-
Notifications
You must be signed in to change notification settings - Fork 307
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
docs: Add a short sections on helpers (#1093)
- Loading branch information
Showing
6 changed files
with
86 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
# Helpers | ||
|
||
Regardless of the way NixVim is used (as a home-manager module, a nixos module, or as a standalone module), | ||
helpers can be included in the same way. | ||
|
||
You can simply use: | ||
|
||
```nix | ||
{ | ||
helpers, | ||
... | ||
}: { | ||
# Your config | ||
} | ||
``` | ||
|
||
A certain number of helpers are defined that can be useful: | ||
|
||
- `helpers.emptyTable`: An empty lua table `{}` that will be included in the final lua configuration. | ||
This is equivalent to `{__empty = {};}`. This form can allow to do `option.__empty = {}`. | ||
|
||
- `helpers.mkRaw str`: Write the string `str` as raw lua in the final lua configuration. | ||
This is equivalent to `{__raw = "lua code";}`. This form can allow to do `option.__raw = "lua code"`. | ||
|
||
- `helpers.toLuaObject obj`: Create a string representation of the Nix object. Useful to define your own plugins. | ||
|
||
- `helpers.listToUnkeyedAttrs list`: Transforms a list to an "unkeyed" attribute set. | ||
|
||
This allows to define mixed table/list in lua: | ||
|
||
```nix | ||
(listToUnkeyedAttrs ["a", "b"]) // {foo = "bar";} | ||
``` | ||
|
||
Resulting in the following lua: | ||
|
||
```lua | ||
{"a", "b", [foo] = "bar"} | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
.SH "OPTIONS" | ||
.PP | ||
You can use the following options in a NixVim module. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,3 +9,4 @@ | |
--- | ||
|
||
[Contributing](./CONTRIBUTING.md) | ||
[Helpers](./helpers.md) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters