Commit graph

11 commits

Author SHA1 Message Date
Matt Sturgeon
b7f419a759
lib: migrate helpers.nixvimTypes -> lib.types 2024-08-21 07:37:11 +01:00
Matt Sturgeon
8f99c3953c
lib/util: add groupListBySize
Splits up a list into many sub-lists based on the given max-size.

e.g.
```nix
groupListBySize 2 [ 1 2 3 4 5 ]
=> [ [ 1 2 ] [ 3 4 ] [ 5 ] ]
```
2024-08-19 00:50:57 +01:00
Matt Sturgeon
0e98d9cf1e
lib/helpers: build recursively 2024-07-28 22:30:11 +01: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
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
Matt Sturgeon
c16533b3f7
lib: add upperFirstChar
A util function to capitalize the first character of a string.
2024-06-07 09:17:29 +01:00
Gaetan Lepage
0ba2ea5416 helpers: add rawKeysAttrs 2024-05-31 21:53:40 +02:00
traxys
62f32bfc71 treewide: Reformat with nixfmt 2024-05-05 22:00:40 +02: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
89cac08ac7 helpers: add toSnakeCase converter 2024-02-02 10:50:35 +01:00
Gaetan Lepage
7164a89f72 lib/helpers: factor out nixvimUtils 2024-01-25 17:05:03 +01:00