Commit graph

89 commits

Author SHA1 Message Date
Austin Horstman
db4c4e5b17 lib/deprecation: expose mkSettingsRenamedOptionModules publicly
Extracted the `optionsRenamedToSettings` implementation
from`mkVimPlugin` and `mkNeovimPlugin` into a new public helper.
2024-08-14 11:20:17 +00:00
Matt Sturgeon
4eb2ad7db7
lib/lua: support nixpkg's "lua-inline" type
See #1935
2024-08-14 00:25:59 +01:00
Matt Sturgeon
27c4c9c210
lib/modules: init with specialArgs helpers 2024-08-02 14:38:38 +01:00
Matt Sturgeon
491ca5cf51
lib: provide an "extended lib" to our modules
lib/extend-lib.nix returns a nixpkg's lib extended with our own
helpers.

This is exposed as `helpers.extendedLib`, but when evaluating our
modules it should be assigned to `specialArgs.lib`.

Outside of our modules you must still access our helpers via
`config.lib.nixvim` or `config.lib.nixvim.extendedLib`.

Within helpers' sub-sections, `lib` is the extended lib.
2024-08-02 14:33:59 +01:00
Matt Sturgeon
7c39d77b9f
lib/helpers: scope each subsection, but offer aliases 2024-08-01 18:05:00 +01:00
Matt Sturgeon
040bab5f55
lib/helpers: call with auto-args
Define `call = callPackageWith { inherit pkgs lib helpers; }`, which can
be used to automatically pass the correct args into helpers files.

`helpers` is passed in recursively.
2024-07-28 22:51:24 +01:00
Matt Sturgeon
0e98d9cf1e
lib/helpers: build recursively 2024-07-28 22:30:11 +01:00
Matt Sturgeon
1b7efacdf4
wrappers: bootstrap "helpers" directly
We don't need to pass a `getHelpers` function in, since we can just
import `../lib/helpers.nix`.
2024-07-08 16:24:06 +01:00
Matt Sturgeon
aff12581d8
lib/lua: refactor toLuaObject, now configurable
Heavily based on nixpkgs lib.generators.toPretty
2024-06-28 22:44:43 +01:00
Matt Sturgeon
01cf43dbaa
lib/lua: add isKeyword and isIdentifier
Allow testing whether a string is a valid lua identifier or a reserved
keyword.
2024-06-26 11:40:52 +01:00
Matt Sturgeon
54d118869b
lib/deprecation: init with mkDeprecatedSubOptionModule
Similar to `lib.mkRemovedOptionModule` but tweaked to work with
sub-options (e.g. settings options).

Also uses warnings instead of assertions.
2024-06-25 15:48:33 +01:00
Matt Sturgeon
69e43a6bf9
plugins/none-ls: refactor mkRaw
- Allow passing raw types through mkRaw
- Throw an error when passing invalid input into mkRaw
2024-06-17 00:01:39 +01:00
traxys
62f32bfc71 treewide: Reformat with nixfmt 2024-05-05 22:00:40 +02:00
Matt Sturgeon
21c233919d
output: format init.lua 2024-04-13 12:46:25 +01:00
Gaetan Lepage
b8815f04a3 helpers/vim-plugin/mkVimPlugin: add optionsRenamedToSettings option 2024-02-19 11:25:29 +01:00
Gaetan Lepage
efdd9f2688 helpers/neovim-plugin/mkNeovimPlugin: add deprecateExtraConfig and optionsRenamedToSettings options 2024-02-18 13:51:17 +01:00
traxys
6d7e429537
tests: Introduce a way to disable options when running in tests (#1095)
In our basic template we used to provide a check based on
`mkTestDerivationFromNvim`. The issue with this check (that is handled
correctly internally) is that some plugins _can't_ be used in the test
environment, for example image.nvim like in #1085.

This commit introduces a new function to generate such checks,
`mkTestDerivationFromNixvimModule`, that wraps a nixvim configuration
instead of a built nvim instance.

Then a configuration can rely on the newly added
`helpers.enableExceptInTests` attribute to disable parts of the
configuration depending if it is evaluated in tests or in a real final
configuration.

Resolves #1085
2024-02-15 14:27:45 +01:00
Gaetan Lepage
44949348cb helpers/neovim-plugin: add mkNeovimPlugin 2024-02-14 09:53:29 +01:00
Gaetan Lepage
304c62516d helpers/autocmd-helpers: do not import helpers.nix directly 2024-02-11 11:50:35 +01:00
Gaetan Lepage
ba818894b4 helpers/keymap-helpers: do not import helpers.nix directly 2024-02-11 11:50:35 +01:00
Gaetan Lepage
e2c3459d1d lib/helpers: extraOptionsOptions -> neovim-plugin.extraOptionsOptions 2024-01-28 23:39:14 +01:00
Gaetan Lepage
7164a89f72 lib/helpers: factor out nixvimUtils 2024-01-25 17:05:03 +01:00
Gaetan Lepage
98dbe8a89b lib/helpers: internal refactoring 2024-01-25 16:38:59 +01:00
Gaetan Lepage
598ac0465f helpers: remove unused toVimDict 2024-01-25 16:38:59 +01:00
Gaetan Lepage
8f90372ee5 helpers: move mkPlugin and mkDefaultOpt to helpers.vim-plugin 2024-01-25 15:19:26 +01:00
Gaetan Lepage
8104e24adc helpers: remove useless comments for certain options 2024-01-17 15:03:54 +01:00
Gaetan Lepage
5ae4714e80 helpers/highlight: Add rawType support for string options in the highlight type 2024-01-17 15:03:54 +01:00
Gaetan Lepage
6e39178dd3 helpers/mkDefaultOpt: make 'global' parameter optional 2024-01-14 22:35:27 +01:00
Gaetan Lepage
f1c8f9a8d2 helpers/mkPlugin: remove useless 'value' parameter 2024-01-14 22:35:27 +01:00
Gaetan Lepage
22fb5df657 helpers/mkPlugin: remove useless bool conversion 2024-01-14 22:35:27 +01:00
Gaetan Lepage
e3ef5dae2b helpers/mkPlugin: add default value for description (use name) 2024-01-14 22:35:27 +01:00
Gaetan Lepage
97fb6d6a29 helpers/mkPlugin: add extraConfig option 2024-01-14 22:35:27 +01:00
Gaetan Lepage
a40a0c679c helpers: add mkNullOrStr 2024-01-06 18:33:39 +01:00
Gaetan Lepage
f0b487a10c helpers: expose maybeRaw for wider use 2024-01-06 16:45:17 +01:00
traxys
8aa4b7e4ce
helpers: Add option helpers for types that are either a lua str or a value (#876)
Those types needed the following code in apply:

if builtins.isString value
then mkRaw value
else value

This commit avoids this boilerplate, and clarifies that the `str` is lua
code in the documentation.
2024-01-02 00:30:10 +01:00
traxys
8b8a1c0f4b
fix: Remove missed mentions of rawType (#875) 2024-01-02 00:26:41 +01:00
traxys
4d14c098b6 helpers: Add types for lua function & lua code
This allows to display `lua function string` and `lua code string` in
the documentation for related options.
2024-01-02 00:15:30 +01:00
Gaetan Lepage
f88ff0a82e helpers: borderType -> nixvimTypes.border 2024-01-01 23:55:27 +01:00
Gaetan Lepage
d88a30fba6 helpers: highlightType -> nixvimTypes.highlight 2024-01-01 23:55:27 +01:00
traxys
af41ea2d80
helpers: move rawType to helpers.nixvimTypes (#871)
This is done in preparation of adding new (lua) types to help the
documentation.
2024-01-01 23:33:53 +01:00
Gaetan Lepage
99ebb5f074 helpers: fix typo 2024-01-01 21:49:35 +01:00
traxys
abd1c4007a
helpers: Add mkLua,mkLuaFn (defaultNullOpts or not) (#866)
This makes it such that defaultNullOpts.mkStr never represents a lua
string, easing documenting where a string is a lua string vs lua code.
2024-01-01 20:28:55 +01:00
traxys
1d8e7906c9
plugins: Introduce helpers.defaultNullOpts.mkLuaFn (#855)
This allows to avoid calling `mkRaw` on lua functions, as they will get
applied automatically.

This could also help in the future to refactor the use of Lua code to
make it more user-friendly.
2023-12-29 15:24:42 +01:00
traxys
e0521dde87
helpers: Allow to set raw lua code in more places (#837)
With this change a user should be able to set raw lua code in more
places than before.

The `mkStr` helper was _not_ changed as a large number of places in
nixvim are using this helper to directly implement raw lua code.

Also note that types of the form `oneOf [submodule <something else>` are
not well rendered in the documentation, and should be avoided (this
includes `listOf [submodule <something else>`, so the helpers should be
avoided in this case)
2023-12-22 16:55:50 +01:00
traxys
2871dc94b4
Allow to add meta options like maintainers (#836) 2023-12-22 15:59:41 +01:00
Gaetan Lepage
a70947a563 lib/helpers: add defaultNullOpts.mkLogLevel 2023-12-22 14:48:15 +01:00
Gaetan Lepage
e49bec3901 lib/helpers: add defaultNullOpts.mkSeverity 2023-12-22 14:48:15 +01:00
Gaetan Lepage
3ff4976eba lib/helpers: mkRaw should output null for empty strings 2023-11-28 14:08:27 +01:00
Gaetan Lepage
8cf2d943d2 lib/helpers: mkRaw now behaves like mkRawIfNonNull 2023-11-23 11:39:41 +01:00
Gaetan Lepage
707054bf23 helpers: factor out borderType 2023-11-16 22:22:18 +01:00