Commit graph

150 commits

Author SHA1 Message Date
Stanislav Asunkin
119f12db27 modules/output: avoid using global with lib; 2024-07-24 16:50:50 +02:00
Stanislav Asunkin
9317537848 modules: avoid setting empty strings to extraConfig* options
Problem:  Some modules are setting empty strings to extraConfig* options
          with the intention to not generate any config. But empty
          strings are also values, so they are still concatenated in the
          final value of extraConfig* options. This results in a
          multiple empty strings in extraConfigs.

Solution: Avoid using optionalString when setting values to extraConfig*
          options. Use mkIf instead.

          This commit also fixes mkIf condition in autocmd module.

          `mkNeovimPlugin` is a special case. To avoid evaluating
          caller's arguments mkMerge/optionalAttrs pattern is used
          instead.
2024-07-22 23:18:53 +02:00
Stanislav Asunkin
299d0406bb modules/output: refactor config generation
The motivation for this change was to avoid generating empty
config sections like

    vim.cmd([[

    ]])

To make a config generation cleaner several helper functions introduced:

* `hasContent` have been moved to helpers
* `concatNonEmptyLines` joins strings (which has content) separated with
  newlines
* `wrapVimscriptForLua` wraps a lua string for using in Vimscript, but
  only if the string has content, otherwise empty string is returned
* `wrapLuaForVimscript` wraps Vimscript for using in lua, but only if
  the string has content, otherwise empty string is returned

Added tests:

* testing that all possible config sections are present in the final
  generated config
* testing that the config files generated by empty `files` definitions
  don't have any content in it
2024-07-22 23:18:53 +02:00
Stanislav Asunkin
34aa3e00e7 modules/filetype: ensure that the module does not set empty settings
When setting any filetype suboption to null (or anything else guarded by
mkIf) it's value becomes:

    { extension = null; filename = null; pattern = null; }

Account for that case in mkIf condition so that the option would not
produce empty filetype definition.
2024-07-22 11:33:52 +03:00
Stanislav Asunkin
8eb5763bbb modules/lua-loader: make enable option nullable
This avoids having the option always "defined".

This also avoids luaLoader configuration in extra files by default.
Earlier `vim.loader.disable()` was always added to configs produced
by `files` option, effectively disabling luaLoader even if it was
explicitly enabled in a top-level configuration.
2024-07-21 17:11:50 +03:00
Stanislav Asunkin
c9a6912be5 modules/files: fix creating configs of vim type 2024-07-19 14:45:34 +03:00
Matt Sturgeon
a6cc4c6c33
modules/files: format files submodule output
Instead of `pkgs.writeText`, use `helpest.writeLua` to ensure the file
is formatted with stylua.
2024-07-07 16:44:17 +01:00
Matt Sturgeon
086873bed9
modules: refactor extraFiles
Moved `extraFiles` from `modules/output.nix` into its own file `modules/files.nix`.

Users should now assign text to a `text` attribute, however they could
also assign a file path to a `source` attribute instead.

The old method of directly assigning a string still works, and is
coerced to the new type along with a deprecation warning.
2024-07-07 16:42:47 +01:00
Stanislav Asunkin
6674dea840 modules/output: fix extraLuaPackages 2024-07-06 20:44:43 +00:00
Matt Sturgeon
04a255ed7e
modules/context: init with isDocs
Replaced the `isDocs` specialArg added in #1807 with an internal module
option.

We should only use `specialArgs` when absolutely necessary, a module or
`_module.args` is preferred, but those aren't available until `config`
is evaluated so they can't be used for `imports`.

The main problem with `specialArgs` is it makes our modules less
portable.

Luckily that shouldn't be an issue for these context flags.
2024-07-06 11:47:41 +01:00
traxys
367380bd84 modules/output: Remove the initContent option
This (internal) option introduces IFD, and can be substituted internally
with the `initPath` option easily.
If the content is required somewhere users can use readFile on the
initPath, though it will result in an IFD in their project.
2024-07-05 22:08:25 +02:00
Matt Sturgeon
38d43a740f
modules/files: don't include modules in the docs
This means we no longer need to spoof the module in the docs implementation.

Instead, we supply the (optional) special arg `isDocs` to `evalModules`.
2024-07-05 17:38:46 +01:00
Matt Sturgeon
f5ba05ec82
modules/files: move submodule to its own file 2024-07-05 17:21:56 +01:00
Matt Sturgeon
2deb61f6a5
modules/top-level: move out of wrappers/modules 2024-07-05 17:20:28 +01:00
Matt Sturgeon
87f50db84d
modules/nixpkgs: don't set args.lib
`lib.evalModules` always includes `lib`, `config`, `options`, &
(configured) `specialArgs` in the (final) `specialArgs`[1].

Therefore, setting `_module.args.lib` has no effect.

[1]: 329d232802/lib/modules.nix (L233)
2024-07-02 20:26:55 +01:00
Matt Sturgeon
11df0d6c9e
modules: use assertions module from nixpkgs
It is essentially identical to our `warnings` module.
2024-07-02 19:58:30 +01:00
Matt Sturgeon
d2afb176ff
modules: refactor module bootstrapping
Let's simplify things by defining all modules in `./plugins`, `./modules`
and `./wrappers/modules`.

Instead of currying `pkgs` into a bootstrapping module, we can require
`defaultPkgs` be provided as a special arg.

This refactor allows us to completely remove `flake-modules/modules.nix`!
2024-07-02 19:58:30 +01:00
Gaetan Lepage
e84881f46f modules/diagnostics: rename source file 2024-06-21 16:10:27 +02:00
Matt Sturgeon
39d1c95061
modules/diagnostic: init 2024-06-21 13:00:01 +01:00
Gaetan Lepage
affee53852 modules: use real nix expressions for option examples 2024-06-20 08:07:10 +02:00
Saien Govender
16db91b37a Fix typo in highlights.nix
Example of highlightOverride used incorrect option name.
2024-06-19 16:17:23 +02:00
Gaetan Lepage
7a2d065cce misc: ensure all options have a description 2024-06-11 11:34:10 +02:00
Matt Sturgeon
37dbf9d2e2
modules/clipboard: use md link in description
Use a markdown-syntax link so that the docs show a clickable-link.
2024-06-05 08:04:33 +01:00
Matt Sturgeon
29922e13f7
modules/keymaps: fix false-positive lua warning 2024-05-31 20:38:53 +01:00
Matt Sturgeon
9b340f8bab
modules/keymaps: more verbose lua deprecation
Include the offending definition(s) in the warning.
2024-05-29 09:21:45 +01:00
Matt Sturgeon
8212bf1cd2 modules/keymaps: deprecate lua option 2024-05-26 15:26:06 +01:00
Nick Hu
1c9f2a23a6 modules/commands: allow commands to be raw lua 2024-05-21 14:27:49 +02:00
Nick Hu
3ec6dff17b modules/commands: fix nargs enum 2024-05-21 14:27:49 +02:00
traxys
62f32bfc71 treewide: Reformat with nixfmt 2024-05-05 22:00:40 +02:00
Gaetan Lepage
f2f97d844b misc: allow null in extraPackages 2024-04-24 08:10:51 +02:00
Matt Sturgeon
4f83bcf290
Rename options to avoid confusion with module options (#1324) 2024-03-29 21:58:44 +01:00
Bodleum
303b9ca2c0
Keymaps: Add keymapsOnEvent to load keymap on specified events (#1260) 2024-03-18 20:41:12 +01:00
Gaetan Lepage
5eae22d14e modules/keymaps: remove deprecation warning 2024-03-02 22:12:58 +01:00
Austin Horstman
30bc345dee modules/highlights: add highlightOverride 2024-02-11 19:53:16 +01:00
Gabriel Arazas
0b5800a2a2
docs: clean up descriptions (#1061) 2024-02-11 13:51:34 +01:00
Gaetan Lepage
3bbb3d5453 modules/highlights: remove useless mkIf 2024-02-09 11:28:51 +01:00
Gaetan Lepage
eec8d6b1b2 misc: import nixvim modules in a simpler way 2024-02-09 08:15:13 +01:00
Austin Horstman
a181b63aaf
modules/highlights: post -> pre loading (#1016) 2024-02-05 01:00:50 +01:00
Gaetan Lepage
2294a12b0b keymaps: use 'action.__raw' instead of 'lua = true' internally 2024-02-03 18:12:25 +01:00
Gaetan Lepage
c97afcbf82 modules/commands: fix lua cmd.options value when no options are set 2024-01-20 14:48:59 +01:00
Peter Tonner
c795b2ee40 misc: fix python packages option name 2024-01-06 21:17:55 +01:00
Gaetan Lepage
d52f656a8b misc: fix python environment options 2024-01-06 20:11:22 +01:00
Gaetan Lepage
1ab5159acf modules: add python options to specify the python environment 2024-01-06 17:39:17 +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
acc9c8cad1 modules/options: improve documentation 2023-12-29 10:52:24 +01:00
Gaetan Lepage
a7144cfbf7 modules/options: refactoring 2023-12-28 11:52:46 +01:00
Gaetan Lepage
02149dbb01 modules/options: add localOptions and globalOptions 2023-12-28 11:52:46 +01:00
Gaetan Lepage
430c8f672b modules/filetype: code formatting 2023-12-09 22:25:49 +01:00
Gaetan Lepage
903e2a1ccb modules/highlight: use double quotes in examples 2023-12-05 11:27:05 +01:00