Moved all function-specific docs from `docs/lib/index.md` into RFC145
doc-comments.
Added `lib.nixvim.lua.toLuaObject` to hold the public docs and serve as
a stable impl of `toLua'` in case we decide to change its defaults.
`lib.generators.toPretty` has bespoke handling for rendering nix strings
using either the `" "` or `'' ''` syntax, based on some heuristics.
Using `toPretty` instead of `toJSON` improves how literal-lua examples
render in the docs.
`nestedLiteral` converts a `literalExpression` into a `toPretty` style
pretty-printer.
`nestedLiteralLua` composes `nestedLiteral` and `literalLua` together.
This commit adds a `plugins.<name>.luaConfig` section controlling the
plugin specific configuration.
The section contains the internal `init` option, containing the plugin's
initialization code.
It also contains the public `pre` and `post` options, that allow to add
code before & after the `init` section
Finally, it contains the `final` option, being the concatenation of the
three previous options.
These functions had very similar bugs: they didn't check if their chosen
"close token" was already present in the string they're escaping.
I went ahead and did the work implied by the TODOs: search for a "close
token" that is *not* in the original string. Pretty simple concept, but
it turned into an annoying amount of code. I couldn't find anything in
upstream nixpkgs lib, or some clever insight about lua/vimscript that
makes this work unecessary, but I'll be thrilled (and a little bummed
about a wasted afternoon) to learn about something.
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
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