2024-04-21 01:10:06 +02:00
|
|
|
{
|
|
|
|
config,
|
|
|
|
lib,
|
|
|
|
...
|
|
|
|
}: let
|
|
|
|
inherit (lib.options) mkOption mkEnableOption literalMD literalExpression;
|
|
|
|
inherit (lib.strings) optionalString;
|
2024-12-01 08:09:13 +01:00
|
|
|
inherit (lib.types) str bool int enum attrsOf lines listOf either path submodule anything;
|
2024-12-10 22:08:48 +01:00
|
|
|
inherit (lib.trivial) isBool;
|
2024-12-02 22:53:22 +01:00
|
|
|
inherit (lib.nvim.languages) toVimBool;
|
2024-04-21 01:10:06 +02:00
|
|
|
inherit (lib.nvim.types) dagOf;
|
|
|
|
inherit (lib.nvim.lua) listToLuaTable;
|
2024-07-20 10:30:48 +02:00
|
|
|
|
2024-04-21 01:10:06 +02:00
|
|
|
cfg = config.vim;
|
|
|
|
in {
|
|
|
|
options.vim = {
|
2024-12-10 21:34:08 +01:00
|
|
|
enableLuaLoader = mkOption {
|
|
|
|
type = bool;
|
|
|
|
default = false;
|
|
|
|
example = true;
|
|
|
|
description = ''
|
|
|
|
[{option}`official documentation`]: https://neovim.io/doc/user/lua.html#vim.loader.enable()
|
|
|
|
|
|
|
|
the experimental Lua module loader to speed up the start up process
|
|
|
|
|
|
|
|
If `true`, this will enable the experimental Lua module loader which:
|
|
|
|
- overrides loadfile
|
|
|
|
- adds the lua loader using the byte-compilation cache
|
|
|
|
- adds the libs loader
|
|
|
|
- removes the default Neovim loader
|
|
|
|
|
|
|
|
::: {.note}
|
|
|
|
The Lua module loader is *disabled* by default. Before setting this option, please
|
|
|
|
take a look at the [{option}`official documentation`]. This option may be enabled by
|
|
|
|
default in the future.
|
|
|
|
:::
|
|
|
|
'';
|
|
|
|
};
|
2024-04-21 01:10:06 +02:00
|
|
|
|
|
|
|
additionalRuntimePaths = mkOption {
|
|
|
|
type = listOf (either path str);
|
|
|
|
default = [];
|
|
|
|
example = literalExpression ''
|
|
|
|
[
|
2024-04-23 20:10:39 +02:00
|
|
|
# absolute path, as a string - impure
|
|
|
|
"$HOME/.config/nvim-extra"
|
|
|
|
|
|
|
|
# relative path, as a path - pure
|
|
|
|
./nvim
|
|
|
|
|
|
|
|
# source type path - pure and reproducible
|
|
|
|
(builtins.source {
|
|
|
|
path = ./runtime;
|
|
|
|
name = "nvim-runtime";
|
|
|
|
})
|
2024-04-21 01:10:06 +02:00
|
|
|
]
|
|
|
|
'';
|
2024-04-21 01:34:47 +02:00
|
|
|
|
2024-04-21 01:10:06 +02:00
|
|
|
description = ''
|
|
|
|
Additional runtime paths that will be appended to the
|
|
|
|
active runtimepath of the Neovim. This can be used to
|
|
|
|
add additional lookup paths for configs, plugins, spell
|
|
|
|
languages and other things you would generally place in
|
2024-05-08 22:49:08 +02:00
|
|
|
your {file}`$HOME/.config/nvim`.
|
2024-04-21 01:10:06 +02:00
|
|
|
|
|
|
|
This is meant as a declarative alternative to throwing
|
2024-05-08 22:49:08 +02:00
|
|
|
files into {file}`~/.config/nvim` and having the Neovim
|
2024-04-21 01:10:06 +02:00
|
|
|
wrapper pick them up. For more details on
|
|
|
|
`vim.o.runtimepath`, and what paths to use; please see
|
|
|
|
[the official documentation](https://neovim.io/doc/user/options.html#'runtimepath')
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
2024-05-08 22:49:08 +02:00
|
|
|
extraLuaFiles = mkOption {
|
|
|
|
type = listOf (either path str);
|
|
|
|
default = [];
|
|
|
|
example = literalExpression ''
|
|
|
|
[
|
|
|
|
# absolute path, as a string - impure
|
|
|
|
"$HOME/.config/nvim/my-lua-file.lua"
|
|
|
|
|
|
|
|
# relative path, as a path - pure
|
|
|
|
./nvim/my-lua-file.lua
|
|
|
|
|
|
|
|
# source type path - pure and reproducible
|
|
|
|
(builtins.source {
|
|
|
|
path = ./nvim/my-lua-file.lua;
|
|
|
|
name = "my-lua-file";
|
|
|
|
})
|
|
|
|
]
|
|
|
|
'';
|
|
|
|
|
|
|
|
description = ''
|
|
|
|
Additional lua files that will be sourced by Neovim.
|
|
|
|
Takes both absolute and relative paths, all of which
|
|
|
|
will be called via the `luafile` command in Neovim.
|
|
|
|
|
|
|
|
See [lua-commands](https://neovim.io/doc/user/lua.html#lua-commands)
|
|
|
|
on the Neovim documentation for more details.
|
|
|
|
|
|
|
|
::: {.warning}
|
|
|
|
All paths passed to this option must be valid. If Neovim cannot
|
2024-11-26 08:36:39 +01:00
|
|
|
resolve the path you are attempting to source, then your configuration
|
2024-05-08 22:49:08 +02:00
|
|
|
will error, and Neovim will not start. Please ensure that all paths
|
|
|
|
are correct before using this option.
|
|
|
|
:::
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
2024-04-21 01:10:06 +02:00
|
|
|
globals = mkOption {
|
2024-11-30 23:36:51 +01:00
|
|
|
default = {};
|
|
|
|
type = submodule {
|
2024-12-01 07:34:35 +01:00
|
|
|
freeformType = attrsOf anything;
|
2024-11-30 23:36:51 +01:00
|
|
|
options = {
|
|
|
|
mapleader = mkOption {
|
|
|
|
type = str;
|
|
|
|
default = " ";
|
2024-12-01 08:09:13 +01:00
|
|
|
description = "The key used for `<leader>` mappings";
|
2024-11-30 23:36:51 +01:00
|
|
|
};
|
2024-12-01 08:09:13 +01:00
|
|
|
|
2024-11-30 23:36:51 +01:00
|
|
|
maplocalleader = mkOption {
|
|
|
|
type = str;
|
|
|
|
default = ",";
|
2024-12-01 08:09:13 +01:00
|
|
|
description = "The key used for `<localleader>` mappings";
|
2024-11-30 23:36:51 +01:00
|
|
|
};
|
2024-12-02 22:40:28 +01:00
|
|
|
|
|
|
|
editorconfig = mkOption {
|
|
|
|
type = bool;
|
|
|
|
default = true;
|
|
|
|
description = ''
|
|
|
|
Whether to enable EditorConfig integration in Neovim.
|
|
|
|
|
|
|
|
This defaults to true as it is enabled by default in stock
|
|
|
|
Neovim, setting this option to false disables EditorConfig
|
|
|
|
integration entirely.
|
|
|
|
|
|
|
|
See [Neovim documentation](https://neovim.io/doc/user/editorconfig.html)
|
|
|
|
for more details on configuring EditorConfig behaviour.
|
|
|
|
'';
|
|
|
|
};
|
2024-11-30 23:36:51 +01:00
|
|
|
};
|
2024-11-30 10:18:53 +01:00
|
|
|
};
|
2024-12-01 07:34:35 +01:00
|
|
|
|
2024-09-28 20:28:17 +02:00
|
|
|
example = {"some_variable" = 42;};
|
2024-04-21 04:19:51 +02:00
|
|
|
description = ''
|
|
|
|
An attribute set containing global variable values
|
|
|
|
for storing vim variables as early as possible. If
|
2024-07-20 10:30:48 +02:00
|
|
|
populated, this option will set vim variables in the
|
|
|
|
built luaConfigRC as the first item.
|
2024-04-21 04:19:51 +02:00
|
|
|
|
2024-09-28 20:28:17 +02:00
|
|
|
::: {.note}
|
|
|
|
`{foo = "bar";}` will set `vim.g.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.
|
|
|
|
:::
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
|
|
|
options = mkOption {
|
|
|
|
default = {};
|
2024-12-01 07:34:35 +01:00
|
|
|
type = submodule {
|
|
|
|
freeformType = attrsOf anything;
|
2024-12-01 08:09:13 +01:00
|
|
|
options = {
|
|
|
|
termguicolors = mkOption {
|
|
|
|
type = bool;
|
|
|
|
default = true;
|
|
|
|
description = "Set terminal up for 256 colours";
|
|
|
|
};
|
|
|
|
|
|
|
|
mouse = mkOption {
|
|
|
|
type = enum ["a" "n" "v" "i" "c"];
|
|
|
|
default = "a";
|
|
|
|
description = ''
|
|
|
|
Set modes for mouse support.
|
|
|
|
|
|
|
|
* a - all
|
|
|
|
* n - normal
|
|
|
|
* v - visual
|
|
|
|
* i - insert
|
|
|
|
* c - command
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
|
|
|
cmdheight = mkOption {
|
|
|
|
type = int;
|
|
|
|
default = 1;
|
|
|
|
description = "Height of the command pane";
|
|
|
|
};
|
|
|
|
|
|
|
|
updatetime = mkOption {
|
|
|
|
type = int;
|
|
|
|
default = 300;
|
|
|
|
description = "The number of milliseconds till Cursor Hold event is fired";
|
|
|
|
};
|
|
|
|
|
|
|
|
tm = mkOption {
|
|
|
|
type = int;
|
|
|
|
default = 500;
|
|
|
|
description = "Timeout in ms that Neovim will wait for mapped action to complete";
|
|
|
|
};
|
|
|
|
|
|
|
|
cursorlineopt = mkOption {
|
|
|
|
type = enum ["line" "screenline" "number" "both"];
|
|
|
|
default = "line";
|
|
|
|
description = "Highlight the text line of the cursor with CursorLine hl-CursorLine";
|
|
|
|
};
|
|
|
|
|
|
|
|
splitbelow = mkOption {
|
|
|
|
type = bool;
|
|
|
|
default = true;
|
|
|
|
description = "New splits will open below instead of on top";
|
|
|
|
};
|
|
|
|
|
|
|
|
splitright = mkOption {
|
|
|
|
type = bool;
|
|
|
|
default = true;
|
|
|
|
description = "New splits will open to the right";
|
|
|
|
};
|
|
|
|
|
|
|
|
autoindent = mkOption {
|
|
|
|
type = bool;
|
|
|
|
default = true;
|
|
|
|
description = "Enable auto indent";
|
|
|
|
};
|
|
|
|
|
|
|
|
wrap = mkOption {
|
|
|
|
type = bool;
|
|
|
|
default = true;
|
|
|
|
description = "Enable word wrapping.";
|
|
|
|
};
|
2024-12-02 22:53:22 +01:00
|
|
|
|
|
|
|
signcolumn = mkOption {
|
2024-12-10 22:08:48 +01:00
|
|
|
type = either str bool;
|
2024-12-02 22:53:22 +01:00
|
|
|
default = true;
|
2024-12-10 22:08:48 +01:00
|
|
|
apply = x:
|
|
|
|
if isBool x
|
|
|
|
then toVimBool x # convert to a yes/no str
|
|
|
|
else x;
|
2024-12-02 22:53:22 +01:00
|
|
|
description = "Show the sign column";
|
|
|
|
};
|
2024-12-01 08:09:13 +01:00
|
|
|
};
|
2024-12-01 07:34:35 +01:00
|
|
|
};
|
|
|
|
|
2024-09-28 20:28:17 +02:00
|
|
|
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.
|
|
|
|
:::
|
2024-04-21 04:19:51 +02:00
|
|
|
'';
|
2024-04-21 01:10:06 +02:00
|
|
|
};
|
|
|
|
|
2024-07-20 10:30:48 +02:00
|
|
|
pluginRC = mkOption {
|
|
|
|
type = either (dagOf lines) str;
|
2024-04-21 01:10:06 +02:00
|
|
|
default = {};
|
2024-07-20 10:30:48 +02:00
|
|
|
description = "The DAG used to configure plugins. If a string is passed, entryAnywhere is automatically applied.";
|
2024-04-21 01:10:06 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
luaConfigPre = mkOption {
|
|
|
|
type = str;
|
|
|
|
default = ''
|
|
|
|
${optionalString (cfg.additionalRuntimePaths != []) ''
|
|
|
|
-- The following list is generated from `vim.additionalRuntimePaths`
|
|
|
|
-- and is used to append additional runtime paths to the
|
|
|
|
-- `runtimepath` option.
|
2024-07-29 16:02:00 +02:00
|
|
|
vim.opt.runtimepath:append(${listToLuaTable cfg.additionalRuntimePaths})
|
2024-04-21 01:10:06 +02:00
|
|
|
''}
|
|
|
|
|
|
|
|
${optionalString cfg.enableLuaLoader "vim.loader.enable()"}
|
|
|
|
'';
|
|
|
|
|
|
|
|
defaultText = literalMD ''
|
|
|
|
By default, this option will **append** paths in
|
2024-04-23 20:10:39 +02:00
|
|
|
[](#opt-vim.additionalRuntimePaths)
|
2024-04-21 01:10:06 +02:00
|
|
|
to the `runtimepath` and enable the experimental Lua module loader
|
2024-04-23 20:10:39 +02:00
|
|
|
if [](#opt-vim.enableLuaLoader) is set to true.
|
2024-04-21 01:10:06 +02:00
|
|
|
'';
|
|
|
|
|
|
|
|
example = literalExpression ''"$${builtins.readFile ./my-lua-config-pre.lua}"'';
|
|
|
|
|
|
|
|
description = ''
|
|
|
|
Verbatim lua code that will be inserted **before**
|
|
|
|
the result of `luaConfigRc` DAG has been resolved.
|
|
|
|
|
|
|
|
This option **does not** take a DAG set, but a string
|
|
|
|
instead. Useful when you'd like to insert contents
|
|
|
|
of lua configs after the DAG result.
|
|
|
|
|
|
|
|
::: {.warning}
|
|
|
|
You do not want to override this option with mkForce
|
|
|
|
It is used internally to set certain options as early
|
|
|
|
as possible and should be avoided unless you know what
|
|
|
|
you're doing. Passing a string to this option will
|
|
|
|
merge it with the default contents.
|
|
|
|
:::
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
|
|
|
luaConfigRC = mkOption {
|
2024-07-20 10:30:48 +02:00
|
|
|
type = either (dagOf lines) str;
|
2024-04-21 01:10:06 +02:00
|
|
|
default = {};
|
|
|
|
description = ''
|
|
|
|
Lua configuration, either as a string or a DAG.
|
|
|
|
|
|
|
|
If this option is passed as a DAG, it will be resolved
|
|
|
|
according to the DAG resolution rules (e.g. entryBefore
|
2024-04-27 14:51:22 +02:00
|
|
|
or entryAfter) as per the **nvf** extended library.
|
2024-04-21 01:10:06 +02:00
|
|
|
'';
|
|
|
|
|
|
|
|
example = literalMD ''
|
|
|
|
```lua
|
|
|
|
-- Set the tab size to 4 spaces
|
|
|
|
vim.opt.tabstop = 4
|
|
|
|
vim.opt.shiftwidth = 4
|
|
|
|
vim.opt.expandtab = true
|
|
|
|
```
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
|
|
|
luaConfigPost = mkOption {
|
|
|
|
type = str;
|
|
|
|
default = "";
|
|
|
|
example = literalExpression ''"$${builtins.readFile ./my-lua-config-post.lua}"'';
|
|
|
|
description = ''
|
|
|
|
Verbatim lua code that will be inserted **after**
|
|
|
|
the result of the `luaConfigRc` DAG has been resolved
|
|
|
|
|
|
|
|
This option **does not** take a DAG set, but a string
|
|
|
|
instead. Useful when you'd like to insert contents
|
|
|
|
of lua configs after the DAG result.
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
2024-07-20 10:30:48 +02:00
|
|
|
builtLuaConfigRC = mkOption {
|
2024-04-21 01:10:06 +02:00
|
|
|
internal = true;
|
|
|
|
type = lines;
|
2024-07-20 10:30:48 +02:00
|
|
|
description = "The built lua config for neovim after resolving the DAG";
|
2024-04-21 01:10:06 +02:00
|
|
|
};
|
|
|
|
};
|
|
|
|
}
|