Compare commits

...

3 commits

Author SHA1 Message Date
bce45d4eeb
docs: add missing changelog entries
Some checks are pending
Set up binary cache / cachix (default) (push) Waiting to run
Set up binary cache / cachix (maximal) (push) Waiting to run
Set up binary cache / cachix (nix) (push) Waiting to run
Validate flake & check documentation / Validate Flake Documentation (docs) (push) Waiting to run
Validate flake & check documentation / Validate Flake Documentation (docs-html) (push) Waiting to run
Validate flake & check documentation / Validate Flake Documentation (docs-json) (push) Waiting to run
Validate flake & check documentation / Validate Flake Documentation (docs-manpages) (push) Waiting to run
Validate flake & check formatting / Validate Flake (push) Waiting to run
Validate flake & check formatting / Formatting via Alejandra (push) Waiting to run
Build and deploy documentation / Check latest commit (push) Waiting to run
Build and deploy documentation / publish (push) Blocked by required conditions
2024-09-28 22:27:20 +03:00
ccea1a6159
dashboard/dashboard-nvim: add setupOpts 2024-09-28 22:18:28 +03:00
raf
ab9a7c1600
modules/wrapper: add vim.options (#386)
* wrapper/rc: add `vim.options`

Translates an attribute set of values into `vim.o` values in a key-value format.

* docs: document addition of optionsScript

* wrapper/rc: don't filter null values in {options,global}Script

* wrapper/rc: add examples to vim.options & vim.globals; wording
2024-09-28 21:28:17 +03:00
6 changed files with 60 additions and 22 deletions

View file

@ -5,16 +5,19 @@ can add code that relies on other code. However, if you don't know what the
entries are called, it's hard to do that, so here is a list of the internal entries are called, it's hard to do that, so here is a list of the internal
entries in nvf: entries in nvf:
`vim.luaConfigRC` (top-level DAG): ## `vim.luaConfigRC` (top-level DAG) {#ch-vim-luaconfigrc}
1. (`luaConfigPre`) - not a part of the actual DAG, instead, it's simply 1. (`luaConfigPre`) - not a part of the actual DAG, instead, it's simply
inserted before the rest of the DAG inserted before the rest of the DAG
2. `globalsScript` - used to set globals defined in `vim.globals` 2. `globalsScript` - used to set globals defined in `vim.globals`
3. `basic` - used to set basic configuration options 3. `basic` - used to set basic configuration options
4. `theme` (this is simply placed before `pluginConfigs`, meaning that surrounding entries don't depend on it) - used to set up the theme, which has to be done before other plugins 4. `optionsScript` - used to set options defined in `vim.o`
5. `pluginConfigs` - the result of the nested `vim.pluginRC` (internal option, 5. `theme` (this is simply placed before `pluginConfigs`, meaning that
see the [Custom Plugins](/index.xhtml#ch-custom-plugins) page for adding your own surrounding entries don't depend on it) - used to set up the theme, which has
plugins) DAG, used to set up internal plugins to be done before other plugins
6. `extraPluginConfigs` - the result of `vim.extraPlugins`, which is not a 6. `pluginConfigs` - the result of the nested `vim.pluginRC` (internal option,
see the [Custom Plugins](/index.xhtml#ch-custom-plugins) page for adding your
own plugins) DAG, used to set up internal plugins
7. `extraPluginConfigs` - the result of `vim.extraPlugins`, which is not a
direct DAG, but is converted to, and resolved as one internally direct DAG, but is converted to, and resolved as one internally
7. `mappings` - the result of `vim.maps` 8. `mappings` - the result of `vim.maps`

View file

@ -187,6 +187,12 @@ everyone.
- Add [python-lsp-server](https://github.com/python-lsp/python-lsp-server) as an - Add [python-lsp-server](https://github.com/python-lsp/python-lsp-server) as an
additional Python LSP server. additional Python LSP server.
- Add [](#opt-vim.options) to set `vim.o` values in in your nvf configuration
without using additional Lua. See option documentation for more details.
- Add [](#opt-vim.dashboard.dashboard-nvim.setupOpts) to allow user
configuration for [dashboard.nvim](https://github.com/nvimdev/dashboard-nvim)
[ppenguin](https://github.com/ppenguin): [ppenguin](https://github.com/ppenguin):
- Telescope: - Telescope:

View file

@ -5,16 +5,17 @@
}: let }: let
inherit (lib.modules) mkIf; inherit (lib.modules) mkIf;
inherit (lib.nvim.dag) entryAnywhere; inherit (lib.nvim.dag) entryAnywhere;
inherit (lib.nvim.lua) toLuaObject;
cfg = config.vim.dashboard.dashboard-nvim; cfg = config.vim.dashboard.dashboard-nvim;
in { in {
config = mkIf cfg.enable { config = mkIf cfg.enable {
vim.startPlugins = [ vim = {
"dashboard-nvim" startPlugins = ["dashboard-nvim"];
];
vim.pluginRC.dashboard-nvim = entryAnywhere '' pluginRC.dashboard-nvim = entryAnywhere ''
require("dashboard").setup{} require("dashboard").setup(${toLuaObject cfg.setupOpts})
''; '';
};
}; };
} }

View file

@ -1,7 +1,9 @@
{lib, ...}: let {lib, ...}: let
inherit (lib.options) mkEnableOption; inherit (lib.options) mkEnableOption;
inherit (lib.nvim.types) mkPluginSetupOption;
in { in {
options.vim.dashboard.dashboard-nvim = { options.vim.dashboard.dashboard-nvim = {
enable = mkEnableOption "Fancy and Blazing Fast start screen plugin of neovim [dashboard.nvim]"; enable = mkEnableOption "Fancy and Blazing Fast start screen plugin of neovim [dashboard.nvim]";
setupOpts = mkPluginSetupOption "dashboard.nvim" {};
}; };
} }

View file

@ -80,10 +80,11 @@
maps); maps);
in { in {
config = let config = let
filterNonNull = attrs: filterAttrs (_: value: value != null) attrs;
globalsScript = globalsScript =
mapAttrsToList (name: value: "vim.g.${name} = ${toLuaObject value}") mapAttrsToList (name: value: "vim.g.${name} = ${toLuaObject value}") cfg.globals;
(filterNonNull cfg.globals);
optionsScript =
mapAttrsToList (name: value: "vim.o.${name} = ${toLuaObject value}") cfg.options;
extraPluginConfigs = resolveDag { extraPluginConfigs = resolveDag {
name = "extra plugin configs"; name = "extra plugin configs";
@ -132,9 +133,12 @@ in {
in { in {
vim = { vim = {
luaConfigRC = { luaConfigRC = {
# `vim.g` and `vim.o`
globalsScript = entryAnywhere (concatLines globalsScript); globalsScript = entryAnywhere (concatLines globalsScript);
# basic optionsScript = entryAfter ["basic"] (concatLines optionsScript);
pluginConfigs = entryAfter ["basic"] pluginConfigs;
# Basic
pluginConfigs = entryAfter ["optionsScript"] pluginConfigs;
extraPluginConfigs = entryAfter ["pluginConfigs"] extraPluginConfigs; extraPluginConfigs = entryAfter ["pluginConfigs"] extraPluginConfigs;
mappings = entryAfter ["extraPluginConfigs"] mappings; mappings = entryAfter ["extraPluginConfigs"] mappings;
}; };

View file

@ -129,16 +129,38 @@ in {
globals = mkOption { globals = mkOption {
type = attrs; type = attrs;
default = {}; default = {};
example = {"some_variable" = 42;};
description = '' description = ''
An attribute set containing global variable values An attribute set containing global variable values
for storing vim variables as early as possible. If for storing vim variables as early as possible. If
populated, this option will set vim variables in the populated, this option will set vim variables in the
built luaConfigRC as the first item. built luaConfigRC as the first item.
E.g. {foo = "bar"} will set `vim.g.foo` to "bar" where ::: {.note}
the type of `bar` in the resulting vimscript will be `{foo = "bar";}` will set `vim.g.foo` to "bar", where
infered from the type of the value in the `{name = value}` the type of `bar` in the resulting Lua value will be
pair. inferred from the type of the value in the `{name = value;}`
pair passed to the option.
:::
'';
};
options = mkOption {
type = attrs;
default = {};
example = {visualbell = true;};
description = ''
An attribute set containing vim options to be set
as early as possible. If populated, this option will
set vim options in the built luaConfigRC after `basic`
and before `pluginConfigs` DAG entries.
::: {.note}
`{foo = "bar";}` will set `vim.o.foo` to "bar", where
the type of `bar` in the resulting Lua value will be
inferred from the type of the value in the`{name = value;}`
pair passed to the option.
:::
''; '';
}; };