https://github.com/nvim-neorg/lua-utils.nvim
A small, curated set of utilities for Neovim plugins.
https://github.com/nvim-neorg/lua-utils.nvim
Last synced: 12 months ago
JSON representation
A small, curated set of utilities for Neovim plugins.
- Host: GitHub
- URL: https://github.com/nvim-neorg/lua-utils.nvim
- Owner: nvim-neorg
- License: mit
- Created: 2024-02-17T13:27:02.000Z (over 2 years ago)
- Default Branch: main
- Last Pushed: 2024-02-17T13:40:19.000Z (over 2 years ago)
- Last Synced: 2025-04-05T01:32:14.369Z (about 1 year ago)
- Language: Lua
- Size: 12.7 KB
- Stars: 26
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
# A Collection of Lua Utilities for Neovim
This repository contains a small set of nicities for performing repetitive tasks within Neovim.
This set may shrink further as the features are included in other, larger "utility kits".
The code you see in this repository is primarily used within [Neorg](https://github.com/nvim-neorg/neorg).
All functions are annotated using [LuaCATS](https://luals.github.io/wiki/annotations).
The highlight of the repository is the `match` function, allowing for complex testing of conditions
in a similar fashion to e.g. Rust. Below is an example:
```lua
local match = require("lua-utils").match
local my_string = "possible-value"
--- @type integer|string|table
local transformed_value = match(my_string) {
["possible-value"] = 10, -- Simple return type.
[{ "value1", "value2" }] = "special-case", -- Handling of many cases.
_ = function() -- Functions will be automatically invoked and their return values propagated.
print("Error: invalid value provided!")
return {}
end,
}
print(transformed_value)
```