2017-11-03 02:34:42 +09:00
|
|
|
{ config, lib, pkgs, ... }:
|
|
|
|
|
|
|
|
let
|
2025-01-30 13:46:03 -06:00
|
|
|
inherit (lib)
|
|
|
|
literalExpression mkEnableOption mkIf mkOption mkRemovedOptionModule types;
|
2017-11-03 02:34:42 +09:00
|
|
|
|
|
|
|
cfg = config.programs.neovim;
|
|
|
|
|
2022-08-23 22:02:05 +02:00
|
|
|
fileType = (import ../lib/file-type.nix {
|
|
|
|
inherit (config.home) homeDirectory;
|
|
|
|
inherit lib pkgs;
|
|
|
|
}).fileType;
|
|
|
|
|
2021-07-26 04:40:07 +02:00
|
|
|
jsonFormat = pkgs.formats.json { };
|
|
|
|
|
2020-09-25 08:08:39 +08:00
|
|
|
pluginWithConfigType = types.submodule {
|
|
|
|
options = {
|
|
|
|
config = mkOption {
|
2022-09-22 10:39:55 +02:00
|
|
|
type = types.nullOr types.lines;
|
2023-07-02 00:45:18 +01:00
|
|
|
description =
|
2022-01-27 16:27:35 +01:00
|
|
|
"Script to configure this plugin. The scripting language should match type.";
|
2022-09-22 10:39:55 +02:00
|
|
|
default = null;
|
2020-09-25 08:08:39 +08:00
|
|
|
};
|
2020-12-10 22:30:16 +01:00
|
|
|
|
2022-01-27 16:27:35 +01:00
|
|
|
type = mkOption {
|
|
|
|
type =
|
|
|
|
types.either (types.enum [ "lua" "viml" "teal" "fennel" ]) types.str;
|
2023-07-02 00:45:18 +01:00
|
|
|
description =
|
2022-01-27 16:27:35 +01:00
|
|
|
"Language used in config. Configurations are aggregated per-language.";
|
|
|
|
default = "viml";
|
|
|
|
};
|
|
|
|
|
2023-07-02 00:45:18 +01:00
|
|
|
optional = mkEnableOption "optional" // {
|
2020-12-10 22:30:16 +01:00
|
|
|
description = "Don't load by default (load with :packadd)";
|
|
|
|
};
|
|
|
|
|
|
|
|
plugin = mkOption {
|
|
|
|
type = types.package;
|
2023-07-02 00:45:18 +01:00
|
|
|
description = "vim plugin";
|
2020-12-10 22:30:16 +01:00
|
|
|
};
|
2022-08-23 22:02:05 +02:00
|
|
|
|
|
|
|
runtime = mkOption {
|
|
|
|
default = { };
|
|
|
|
# passing actual "${xdg.configHome}/nvim" as basePath was a bit tricky
|
|
|
|
# due to how fileType.target is implemented
|
2023-05-22 22:48:23 +02:00
|
|
|
type = fileType "programs.neovim.plugins._.runtime"
|
2023-06-30 06:22:38 +01:00
|
|
|
"{var}`xdg.configHome/nvim`" "nvim";
|
2022-08-23 22:02:05 +02:00
|
|
|
example = literalExpression ''
|
|
|
|
{ "ftplugin/c.vim".text = "setlocal omnifunc=v:lua.vim.lsp.omnifunc"; }
|
|
|
|
'';
|
2023-07-02 00:45:18 +01:00
|
|
|
description = ''
|
2022-08-23 22:02:05 +02:00
|
|
|
Set of files that have to be linked in nvim config folder.
|
|
|
|
'';
|
|
|
|
};
|
2020-09-25 08:08:39 +08:00
|
|
|
};
|
|
|
|
};
|
|
|
|
|
2025-01-30 13:46:03 -06:00
|
|
|
allPlugins = cfg.plugins ++ lib.optional cfg.coc.enable {
|
2022-03-17 20:43:03 -06:00
|
|
|
type = "viml";
|
2022-05-21 11:12:29 -06:00
|
|
|
plugin = cfg.coc.package;
|
2022-03-17 20:43:03 -06:00
|
|
|
config = cfg.coc.pluginConfig;
|
|
|
|
optional = false;
|
|
|
|
};
|
|
|
|
|
neovim: fix extraLuaPackages type. (#3533)
Assigning to `programs.neovim.extraLuaPackages` a function taking a lua package set as input
and returning a list of packages, as described in the documentation,
threw an error because the rest of the code assumed that the value was always a plain list.
Using `lib.types.coercedTo`, we can accept such functions, as per the documentation,
as well as plain lists, which we then convert to a function ignoring its input argument.
We print a warning when a plain list is assigned, since the function
form is preferred, as it ensures that the right lua package set is used.
For the lua packages, we also get the lua package set from the
finalPackage, to make sure that we are always using the same package set
as the actual unwrapped neovim package being built.
For `programs.neovim.extraPythonPackages` I did the same.
I updated the test case so that we test both ways of setting these options.
2022-12-29 01:48:45 +01:00
|
|
|
luaPackages = cfg.finalPackage.unwrapped.lua.pkgs;
|
|
|
|
resolvedExtraLuaPackages = cfg.extraLuaPackages luaPackages;
|
|
|
|
|
2020-10-12 22:50:49 +02:00
|
|
|
extraMakeWrapperArgs = lib.optionalString (cfg.extraPackages != [ ])
|
2021-02-06 20:43:17 +01:00
|
|
|
''--suffix PATH : "${lib.makeBinPath cfg.extraPackages}"'';
|
neovim: fix extraLuaPackages type. (#3533)
Assigning to `programs.neovim.extraLuaPackages` a function taking a lua package set as input
and returning a list of packages, as described in the documentation,
threw an error because the rest of the code assumed that the value was always a plain list.
Using `lib.types.coercedTo`, we can accept such functions, as per the documentation,
as well as plain lists, which we then convert to a function ignoring its input argument.
We print a warning when a plain list is assigned, since the function
form is preferred, as it ensures that the right lua package set is used.
For the lua packages, we also get the lua package set from the
finalPackage, to make sure that we are always using the same package set
as the actual unwrapped neovim package being built.
For `programs.neovim.extraPythonPackages` I did the same.
I updated the test case so that we test both ways of setting these options.
2022-12-29 01:48:45 +01:00
|
|
|
extraMakeWrapperLuaCArgs =
|
|
|
|
lib.optionalString (resolvedExtraLuaPackages != [ ]) ''
|
|
|
|
--suffix LUA_CPATH ";" "${
|
|
|
|
lib.concatMapStringsSep ";" luaPackages.getLuaCPath
|
|
|
|
resolvedExtraLuaPackages
|
|
|
|
}"'';
|
|
|
|
extraMakeWrapperLuaArgs = lib.optionalString (resolvedExtraLuaPackages != [ ])
|
|
|
|
''
|
|
|
|
--suffix LUA_PATH ";" "${
|
|
|
|
lib.concatMapStringsSep ";" luaPackages.getLuaPath
|
|
|
|
resolvedExtraLuaPackages
|
|
|
|
}"'';
|
2020-10-12 22:50:49 +02:00
|
|
|
in {
|
2021-05-04 05:47:08 +02:00
|
|
|
imports = [
|
|
|
|
(mkRemovedOptionModule [ "programs" "neovim" "withPython" ]
|
|
|
|
"Python2 support has been removed from neovim.")
|
|
|
|
(mkRemovedOptionModule [ "programs" "neovim" "extraPythonPackages" ]
|
|
|
|
"Python2 support has been removed from neovim.")
|
2022-08-26 22:11:34 +02:00
|
|
|
(mkRemovedOptionModule [ "programs" "neovim" "configure" ] ''
|
|
|
|
programs.neovim.configure is deprecated.
|
|
|
|
Other programs.neovim options can override its settings or ignore them.
|
|
|
|
Please use the other options at your disposal:
|
|
|
|
configure.packages.*.opt -> programs.neovim.plugins = [ { plugin = ...; optional = true; }]
|
|
|
|
configure.packages.*.start -> programs.neovim.plugins = [ { plugin = ...; }]
|
|
|
|
configure.customRC -> programs.neovim.extraConfig
|
|
|
|
'')
|
2021-05-04 05:47:08 +02:00
|
|
|
];
|
2025-01-30 12:25:14 -06:00
|
|
|
|
|
|
|
meta.maintainers = with lib.maintainers; [ khaneliman ];
|
2021-05-04 05:47:08 +02:00
|
|
|
|
2017-11-03 02:34:42 +09:00
|
|
|
options = {
|
|
|
|
programs.neovim = {
|
2023-07-02 00:45:18 +01:00
|
|
|
enable = mkEnableOption "Neovim";
|
2017-11-03 02:34:42 +09:00
|
|
|
|
2018-08-18 04:50:49 +02:00
|
|
|
viAlias = mkOption {
|
|
|
|
type = types.bool;
|
|
|
|
default = false;
|
2023-07-02 00:45:18 +01:00
|
|
|
description = ''
|
2023-07-01 00:30:13 +01:00
|
|
|
Symlink {command}`vi` to {command}`nvim` binary.
|
2018-08-18 04:50:49 +02:00
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
|
|
|
vimAlias = mkOption {
|
|
|
|
type = types.bool;
|
|
|
|
default = false;
|
2023-07-02 00:45:18 +01:00
|
|
|
description = ''
|
2023-07-01 00:30:13 +01:00
|
|
|
Symlink {command}`vim` to {command}`nvim` binary.
|
2018-08-18 04:50:49 +02:00
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
2020-02-26 16:52:04 -08:00
|
|
|
vimdiffAlias = mkOption {
|
|
|
|
type = types.bool;
|
|
|
|
default = false;
|
2023-07-02 00:45:18 +01:00
|
|
|
description = ''
|
2023-07-01 00:30:13 +01:00
|
|
|
Alias {command}`vimdiff` to {command}`nvim -d`.
|
2020-02-26 16:52:04 -08:00
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
2018-11-27 11:21:37 +00:00
|
|
|
withNodeJs = mkOption {
|
|
|
|
type = types.bool;
|
|
|
|
default = false;
|
2023-07-02 00:45:18 +01:00
|
|
|
description = ''
|
2023-07-01 00:30:13 +01:00
|
|
|
Enable node provider. Set to `true` to
|
2018-11-27 11:21:37 +00:00
|
|
|
use Node plugins.
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
2017-11-03 02:34:42 +09:00
|
|
|
withRuby = mkOption {
|
|
|
|
type = types.nullOr types.bool;
|
|
|
|
default = true;
|
2023-07-02 00:45:18 +01:00
|
|
|
description = ''
|
2017-11-03 02:34:42 +09:00
|
|
|
Enable ruby provider.
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
|
|
|
withPython3 = mkOption {
|
|
|
|
type = types.bool;
|
|
|
|
default = true;
|
2023-07-02 00:45:18 +01:00
|
|
|
description = ''
|
2023-07-01 00:30:13 +01:00
|
|
|
Enable Python 3 provider. Set to `true` to
|
2017-11-03 02:34:42 +09:00
|
|
|
use Python 3 plugins.
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
|
|
|
extraPython3Packages = mkOption {
|
neovim: fix extraLuaPackages type. (#3533)
Assigning to `programs.neovim.extraLuaPackages` a function taking a lua package set as input
and returning a list of packages, as described in the documentation,
threw an error because the rest of the code assumed that the value was always a plain list.
Using `lib.types.coercedTo`, we can accept such functions, as per the documentation,
as well as plain lists, which we then convert to a function ignoring its input argument.
We print a warning when a plain list is assigned, since the function
form is preferred, as it ensures that the right lua package set is used.
For the lua packages, we also get the lua package set from the
finalPackage, to make sure that we are always using the same package set
as the actual unwrapped neovim package being built.
For `programs.neovim.extraPythonPackages` I did the same.
I updated the test case so that we test both ways of setting these options.
2022-12-29 01:48:45 +01:00
|
|
|
# In case we get a plain list, we need to turn it into a function,
|
|
|
|
# as expected by the function in nixpkgs.
|
|
|
|
# The only way to do so is to call `const`, which will ignore its input.
|
2025-01-30 13:46:03 -06:00
|
|
|
type = let fromType = types.listOf types.package;
|
|
|
|
in types.coercedTo fromType (lib.flip lib.warn lib.const ''
|
|
|
|
Assigning a plain list to extraPython3Packages is deprecated.
|
|
|
|
Please assign a function taking a package set as argument, so
|
|
|
|
extraPython3Packages = [ pkgs.python3Packages.xxx ];
|
|
|
|
should become
|
|
|
|
extraPython3Packages = ps: [ ps.xxx ];
|
|
|
|
'') (types.functionTo fromType);
|
neovim: fix extraLuaPackages type. (#3533)
Assigning to `programs.neovim.extraLuaPackages` a function taking a lua package set as input
and returning a list of packages, as described in the documentation,
threw an error because the rest of the code assumed that the value was always a plain list.
Using `lib.types.coercedTo`, we can accept such functions, as per the documentation,
as well as plain lists, which we then convert to a function ignoring its input argument.
We print a warning when a plain list is assigned, since the function
form is preferred, as it ensures that the right lua package set is used.
For the lua packages, we also get the lua package set from the
finalPackage, to make sure that we are always using the same package set
as the actual unwrapped neovim package being built.
For `programs.neovim.extraPythonPackages` I did the same.
I updated the test case so that we test both ways of setting these options.
2022-12-29 01:48:45 +01:00
|
|
|
default = _: [ ];
|
2022-06-13 18:57:41 +01:00
|
|
|
defaultText = literalExpression "ps: [ ]";
|
neovim: fix extraLuaPackages type. (#3533)
Assigning to `programs.neovim.extraLuaPackages` a function taking a lua package set as input
and returning a list of packages, as described in the documentation,
threw an error because the rest of the code assumed that the value was always a plain list.
Using `lib.types.coercedTo`, we can accept such functions, as per the documentation,
as well as plain lists, which we then convert to a function ignoring its input argument.
We print a warning when a plain list is assigned, since the function
form is preferred, as it ensures that the right lua package set is used.
For the lua packages, we also get the lua package set from the
finalPackage, to make sure that we are always using the same package set
as the actual unwrapped neovim package being built.
For `programs.neovim.extraPythonPackages` I did the same.
I updated the test case so that we test both ways of setting these options.
2022-12-29 01:48:45 +01:00
|
|
|
example =
|
|
|
|
literalExpression "pyPkgs: with pyPkgs; [ python-language-server ]";
|
2023-07-02 00:45:18 +01:00
|
|
|
description = ''
|
neovim: fix extraLuaPackages type. (#3533)
Assigning to `programs.neovim.extraLuaPackages` a function taking a lua package set as input
and returning a list of packages, as described in the documentation,
threw an error because the rest of the code assumed that the value was always a plain list.
Using `lib.types.coercedTo`, we can accept such functions, as per the documentation,
as well as plain lists, which we then convert to a function ignoring its input argument.
We print a warning when a plain list is assigned, since the function
form is preferred, as it ensures that the right lua package set is used.
For the lua packages, we also get the lua package set from the
finalPackage, to make sure that we are always using the same package set
as the actual unwrapped neovim package being built.
For `programs.neovim.extraPythonPackages` I did the same.
I updated the test case so that we test both ways of setting these options.
2022-12-29 01:48:45 +01:00
|
|
|
The extra Python 3 packages required for your plugins to work.
|
|
|
|
This option accepts a function that takes a Python 3 package set as an argument,
|
|
|
|
and selects the required Python 3 packages from this package set.
|
|
|
|
See the example for more info.
|
2017-11-03 02:34:42 +09:00
|
|
|
'';
|
|
|
|
};
|
2018-01-31 17:14:01 +09:00
|
|
|
|
neovim: fix extraLuaPackages type. (#3533)
Assigning to `programs.neovim.extraLuaPackages` a function taking a lua package set as input
and returning a list of packages, as described in the documentation,
threw an error because the rest of the code assumed that the value was always a plain list.
Using `lib.types.coercedTo`, we can accept such functions, as per the documentation,
as well as plain lists, which we then convert to a function ignoring its input argument.
We print a warning when a plain list is assigned, since the function
form is preferred, as it ensures that the right lua package set is used.
For the lua packages, we also get the lua package set from the
finalPackage, to make sure that we are always using the same package set
as the actual unwrapped neovim package being built.
For `programs.neovim.extraPythonPackages` I did the same.
I updated the test case so that we test both ways of setting these options.
2022-12-29 01:48:45 +01:00
|
|
|
# We get the Lua package from the final package and use its
|
|
|
|
# Lua packageset to evaluate the function that this option was set to.
|
|
|
|
# This ensures that we always use the same Lua version as the Neovim package.
|
2022-02-16 15:38:10 +00:00
|
|
|
extraLuaPackages = mkOption {
|
2025-01-30 13:46:03 -06:00
|
|
|
type = let fromType = types.listOf types.package;
|
|
|
|
in types.coercedTo fromType (lib.flip lib.warn lib.const ''
|
|
|
|
Assigning a plain list to extraLuaPackages is deprecated.
|
|
|
|
Please assign a function taking a package set as argument, so
|
|
|
|
extraLuaPackages = [ pkgs.lua51Packages.xxx ];
|
|
|
|
should become
|
|
|
|
extraLuaPackages = ps: [ ps.xxx ];
|
|
|
|
'') (types.functionTo fromType);
|
neovim: fix extraLuaPackages type. (#3533)
Assigning to `programs.neovim.extraLuaPackages` a function taking a lua package set as input
and returning a list of packages, as described in the documentation,
threw an error because the rest of the code assumed that the value was always a plain list.
Using `lib.types.coercedTo`, we can accept such functions, as per the documentation,
as well as plain lists, which we then convert to a function ignoring its input argument.
We print a warning when a plain list is assigned, since the function
form is preferred, as it ensures that the right lua package set is used.
For the lua packages, we also get the lua package set from the
finalPackage, to make sure that we are always using the same package set
as the actual unwrapped neovim package being built.
For `programs.neovim.extraPythonPackages` I did the same.
I updated the test case so that we test both ways of setting these options.
2022-12-29 01:48:45 +01:00
|
|
|
default = _: [ ];
|
|
|
|
defaultText = literalExpression "ps: [ ]";
|
|
|
|
example = literalExpression "luaPkgs: with luaPkgs; [ luautf8 ]";
|
2023-07-02 00:45:18 +01:00
|
|
|
description = ''
|
neovim: fix extraLuaPackages type. (#3533)
Assigning to `programs.neovim.extraLuaPackages` a function taking a lua package set as input
and returning a list of packages, as described in the documentation,
threw an error because the rest of the code assumed that the value was always a plain list.
Using `lib.types.coercedTo`, we can accept such functions, as per the documentation,
as well as plain lists, which we then convert to a function ignoring its input argument.
We print a warning when a plain list is assigned, since the function
form is preferred, as it ensures that the right lua package set is used.
For the lua packages, we also get the lua package set from the
finalPackage, to make sure that we are always using the same package set
as the actual unwrapped neovim package being built.
For `programs.neovim.extraPythonPackages` I did the same.
I updated the test case so that we test both ways of setting these options.
2022-12-29 01:48:45 +01:00
|
|
|
The extra Lua packages required for your plugins to work.
|
|
|
|
This option accepts a function that takes a Lua package set as an argument,
|
|
|
|
and selects the required Lua packages from this package set.
|
|
|
|
See the example for more info.
|
2022-02-16 15:38:10 +00:00
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
2024-04-13 23:50:15 +09:00
|
|
|
extraWrapperArgs = mkOption {
|
|
|
|
type = with types; listOf str;
|
|
|
|
default = [ ];
|
|
|
|
example = literalExpression ''
|
|
|
|
[
|
|
|
|
"--suffix"
|
|
|
|
"LIBRARY_PATH"
|
|
|
|
":"
|
|
|
|
"''${lib.makeLibraryPath [ pkgs.stdenv.cc.cc pkgs.zlib ]}"
|
|
|
|
"--suffix"
|
|
|
|
"PKG_CONFIG_PATH"
|
|
|
|
":"
|
|
|
|
"''${lib.makeSearchPathOutput "dev" "lib/pkgconfig" [ pkgs.stdenv.cc.cc pkgs.zlib ]}"
|
|
|
|
]
|
|
|
|
'';
|
|
|
|
description = ''
|
|
|
|
Extra arguments to be passed to the neovim wrapper.
|
|
|
|
This option sets environment variables required for building and running binaries
|
|
|
|
with external package managers like mason.nvim.
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
2021-07-27 15:59:50 +02:00
|
|
|
generatedConfigViml = mkOption {
|
|
|
|
type = types.lines;
|
|
|
|
visible = true;
|
|
|
|
readOnly = true;
|
2023-07-02 00:45:18 +01:00
|
|
|
description = ''
|
2021-07-27 15:59:50 +02:00
|
|
|
Generated vimscript config.
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
2022-01-27 16:27:35 +01:00
|
|
|
generatedConfigs = mkOption {
|
|
|
|
type = types.attrsOf types.lines;
|
|
|
|
visible = true;
|
|
|
|
readOnly = true;
|
|
|
|
example = literalExpression ''
|
|
|
|
{
|
|
|
|
viml = '''
|
|
|
|
" Generated by home-manager
|
2022-08-23 22:02:05 +02:00
|
|
|
map <leader> ,
|
2022-01-27 16:27:35 +01:00
|
|
|
''';
|
|
|
|
|
|
|
|
lua = '''
|
|
|
|
-- Generated by home-manager
|
|
|
|
vim.opt.background = "dark"
|
|
|
|
''';
|
|
|
|
}'';
|
2023-07-02 00:45:18 +01:00
|
|
|
description = ''
|
2022-01-27 16:27:35 +01:00
|
|
|
Generated configurations with as key their language (set via type).
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
2019-02-04 14:57:26 +09:00
|
|
|
package = mkOption {
|
|
|
|
type = types.package;
|
|
|
|
default = pkgs.neovim-unwrapped;
|
2021-10-09 11:14:08 +02:00
|
|
|
defaultText = literalExpression "pkgs.neovim-unwrapped";
|
2023-07-02 00:45:18 +01:00
|
|
|
description = "The package to use for the neovim binary.";
|
2019-02-04 14:57:26 +09:00
|
|
|
};
|
|
|
|
|
2019-08-10 13:55:05 +02:00
|
|
|
finalPackage = mkOption {
|
|
|
|
type = types.package;
|
|
|
|
readOnly = true;
|
2023-07-02 00:45:18 +01:00
|
|
|
description = "Resulting customized neovim package.";
|
2019-08-10 13:55:05 +02:00
|
|
|
};
|
|
|
|
|
2022-12-29 22:36:05 +01:00
|
|
|
defaultEditor = mkOption {
|
|
|
|
type = types.bool;
|
|
|
|
default = false;
|
2023-07-02 00:45:18 +01:00
|
|
|
description = ''
|
2023-07-01 00:30:13 +01:00
|
|
|
Whether to configure {command}`nvim` as the default
|
|
|
|
editor using the {env}`EDITOR` environment variable.
|
2022-12-29 22:36:05 +01:00
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
2019-08-18 15:20:17 +02:00
|
|
|
extraConfig = mkOption {
|
|
|
|
type = types.lines;
|
|
|
|
default = "";
|
|
|
|
example = ''
|
|
|
|
set nobackup
|
|
|
|
'';
|
2023-07-02 00:45:18 +01:00
|
|
|
description = ''
|
2019-08-18 15:20:17 +02:00
|
|
|
Custom vimrc lines.
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
2023-02-05 12:09:26 +01:00
|
|
|
extraLuaConfig = mkOption {
|
|
|
|
type = types.lines;
|
|
|
|
default = "";
|
|
|
|
example = ''
|
|
|
|
vim.opt.nobackup = true
|
|
|
|
'';
|
2023-07-02 00:45:18 +01:00
|
|
|
description = ''
|
2023-02-05 12:09:26 +01:00
|
|
|
Custom lua lines.
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
2020-10-10 16:15:42 +02:00
|
|
|
extraPackages = mkOption {
|
|
|
|
type = with types; listOf package;
|
|
|
|
default = [ ];
|
2022-06-13 18:57:41 +01:00
|
|
|
example = literalExpression "[ pkgs.shfmt ]";
|
2023-07-02 00:45:18 +01:00
|
|
|
description = "Extra packages available to nvim.";
|
2020-10-10 16:15:42 +02:00
|
|
|
};
|
|
|
|
|
2019-08-18 15:20:17 +02:00
|
|
|
plugins = mkOption {
|
2020-09-25 08:08:39 +08:00
|
|
|
type = with types; listOf (either package pluginWithConfigType);
|
2019-08-18 15:20:17 +02:00
|
|
|
default = [ ];
|
2021-10-09 11:14:08 +02:00
|
|
|
example = literalExpression ''
|
2020-09-25 08:08:39 +08:00
|
|
|
with pkgs.vimPlugins; [
|
|
|
|
yankring
|
|
|
|
vim-nix
|
|
|
|
{ plugin = vim-startify;
|
|
|
|
config = "let g:startify_change_to_vcs_root = 0";
|
|
|
|
}
|
|
|
|
]
|
|
|
|
'';
|
2023-07-02 00:45:18 +01:00
|
|
|
description = ''
|
2020-09-25 08:08:39 +08:00
|
|
|
List of vim plugins to install optionally associated with
|
|
|
|
configuration to be placed in init.vim.
|
2019-08-18 15:20:17 +02:00
|
|
|
|
2023-07-01 00:30:13 +01:00
|
|
|
This option is mutually exclusive with {var}`configure`.
|
2018-01-31 17:14:01 +09:00
|
|
|
'';
|
|
|
|
};
|
2021-07-26 04:40:07 +02:00
|
|
|
|
|
|
|
coc = {
|
2023-07-02 00:45:18 +01:00
|
|
|
enable = mkEnableOption "Coc";
|
2021-07-26 04:40:07 +02:00
|
|
|
|
2022-05-21 11:12:29 -06:00
|
|
|
package = mkOption {
|
|
|
|
type = types.package;
|
|
|
|
default = pkgs.vimPlugins.coc-nvim;
|
|
|
|
defaultText = literalExpression "pkgs.vimPlugins.coc-nvim";
|
2023-07-02 00:45:18 +01:00
|
|
|
description = "The package to use for the CoC plugin.";
|
2022-05-21 11:12:29 -06:00
|
|
|
};
|
|
|
|
|
2021-07-26 04:40:07 +02:00
|
|
|
settings = mkOption {
|
neovim: fix extraLuaPackages type. (#3533)
Assigning to `programs.neovim.extraLuaPackages` a function taking a lua package set as input
and returning a list of packages, as described in the documentation,
threw an error because the rest of the code assumed that the value was always a plain list.
Using `lib.types.coercedTo`, we can accept such functions, as per the documentation,
as well as plain lists, which we then convert to a function ignoring its input argument.
We print a warning when a plain list is assigned, since the function
form is preferred, as it ensures that the right lua package set is used.
For the lua packages, we also get the lua package set from the
finalPackage, to make sure that we are always using the same package set
as the actual unwrapped neovim package being built.
For `programs.neovim.extraPythonPackages` I did the same.
I updated the test case so that we test both ways of setting these options.
2022-12-29 01:48:45 +01:00
|
|
|
inherit (jsonFormat) type;
|
2021-07-26 04:40:07 +02:00
|
|
|
default = { };
|
2021-10-09 11:14:08 +02:00
|
|
|
example = literalExpression ''
|
2021-07-26 04:40:07 +02:00
|
|
|
{
|
|
|
|
"suggest.noselect" = true;
|
|
|
|
"suggest.enablePreview" = true;
|
|
|
|
"suggest.enablePreselect" = false;
|
|
|
|
"suggest.disableKind" = true;
|
|
|
|
languageserver = {
|
|
|
|
haskell = {
|
|
|
|
command = "haskell-language-server-wrapper";
|
|
|
|
args = [ "--lsp" ];
|
|
|
|
rootPatterns = [
|
|
|
|
"*.cabal"
|
|
|
|
"stack.yaml"
|
|
|
|
"cabal.project"
|
|
|
|
"package.yaml"
|
|
|
|
"hie.yaml"
|
|
|
|
];
|
|
|
|
filetypes = [ "haskell" "lhaskell" ];
|
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
|
|
|
'';
|
2023-07-02 00:45:18 +01:00
|
|
|
description = ''
|
2021-07-26 04:40:07 +02:00
|
|
|
Extra configuration lines to add to
|
2023-07-01 00:30:13 +01:00
|
|
|
{file}`$XDG_CONFIG_HOME/nvim/coc-settings.json`
|
2021-07-26 04:40:07 +02:00
|
|
|
See
|
2023-07-01 00:30:13 +01:00
|
|
|
<https://github.com/neoclide/coc.nvim/wiki/Using-the-configuration-file>
|
2021-07-26 04:40:07 +02:00
|
|
|
for options.
|
|
|
|
'';
|
|
|
|
};
|
2022-03-17 20:43:03 -06:00
|
|
|
|
|
|
|
pluginConfig = mkOption {
|
|
|
|
type = types.lines;
|
|
|
|
default = "";
|
2023-07-02 00:45:18 +01:00
|
|
|
description = "Script to configure CoC. Must be viml.";
|
2022-03-17 20:43:03 -06:00
|
|
|
};
|
2021-07-26 04:40:07 +02:00
|
|
|
};
|
2017-11-03 02:34:42 +09:00
|
|
|
};
|
|
|
|
};
|
|
|
|
|
2020-12-29 20:26:02 +01:00
|
|
|
config = let
|
2022-08-23 22:02:05 +02:00
|
|
|
defaultPlugin = {
|
|
|
|
type = "viml";
|
|
|
|
plugin = null;
|
2022-09-22 10:39:55 +02:00
|
|
|
config = null;
|
2022-08-23 22:02:05 +02:00
|
|
|
optional = false;
|
|
|
|
runtime = { };
|
|
|
|
};
|
|
|
|
|
|
|
|
# transform all plugins into a standardized attrset
|
|
|
|
pluginsNormalized =
|
|
|
|
map (x: defaultPlugin // (if (x ? plugin) then x else { plugin = x; }))
|
|
|
|
allPlugins;
|
|
|
|
|
2022-01-27 16:27:35 +01:00
|
|
|
suppressNotVimlConfig = p:
|
2022-09-22 10:39:55 +02:00
|
|
|
if p.type != "viml" then p // { config = null; } else p;
|
2022-01-27 16:27:35 +01:00
|
|
|
|
2020-12-29 20:26:02 +01:00
|
|
|
neovimConfig = pkgs.neovimUtils.makeNeovimConfig {
|
2022-03-17 20:43:03 -06:00
|
|
|
inherit (cfg) extraPython3Packages withPython3 withRuby viAlias vimAlias;
|
2022-06-22 16:14:18 -04:00
|
|
|
withNodeJs = cfg.withNodeJs || cfg.coc.enable;
|
2022-03-17 20:43:03 -06:00
|
|
|
plugins = map suppressNotVimlConfig pluginsNormalized;
|
2021-05-28 04:05:20 +08:00
|
|
|
customRC = cfg.extraConfig;
|
2020-12-29 20:26:02 +01:00
|
|
|
};
|
|
|
|
|
2024-10-21 17:58:46 -05:00
|
|
|
wrappedNeovim' = pkgs.wrapNeovimUnstable cfg.package (neovimConfig // {
|
|
|
|
wrapperArgs =
|
|
|
|
(lib.escapeShellArgs (neovimConfig.wrapperArgs ++ cfg.extraWrapperArgs))
|
|
|
|
+ " " + extraMakeWrapperArgs + " " + extraMakeWrapperLuaCArgs + " "
|
|
|
|
+ extraMakeWrapperLuaArgs;
|
|
|
|
wrapRc = false;
|
|
|
|
});
|
2020-12-29 20:26:02 +01:00
|
|
|
in mkIf cfg.enable {
|
2019-08-18 15:20:17 +02:00
|
|
|
|
2021-07-27 15:59:50 +02:00
|
|
|
programs.neovim.generatedConfigViml = neovimConfig.neovimRcContent;
|
|
|
|
|
2022-01-27 16:27:35 +01:00
|
|
|
programs.neovim.generatedConfigs = let
|
|
|
|
grouped = lib.lists.groupBy (x: x.type) pluginsNormalized;
|
2022-02-25 08:35:13 -05:00
|
|
|
concatConfigs = lib.concatMapStrings (p: p.config);
|
2022-09-22 10:39:55 +02:00
|
|
|
configsOnly = lib.foldl
|
neovim: fix extraLuaPackages type. (#3533)
Assigning to `programs.neovim.extraLuaPackages` a function taking a lua package set as input
and returning a list of packages, as described in the documentation,
threw an error because the rest of the code assumed that the value was always a plain list.
Using `lib.types.coercedTo`, we can accept such functions, as per the documentation,
as well as plain lists, which we then convert to a function ignoring its input argument.
We print a warning when a plain list is assigned, since the function
form is preferred, as it ensures that the right lua package set is used.
For the lua packages, we also get the lua package set from the
finalPackage, to make sure that we are always using the same package set
as the actual unwrapped neovim package being built.
For `programs.neovim.extraPythonPackages` I did the same.
I updated the test case so that we test both ways of setting these options.
2022-12-29 01:48:45 +01:00
|
|
|
(acc: p: if p.config != null then acc ++ [ p.config ] else acc) [ ];
|
2025-01-30 13:46:03 -06:00
|
|
|
in lib.mapAttrs (name: vals: lib.concatStringsSep "\n" (configsOnly vals))
|
2022-09-22 10:39:55 +02:00
|
|
|
grouped;
|
2022-01-27 16:27:35 +01:00
|
|
|
|
2019-08-10 13:55:05 +02:00
|
|
|
home.packages = [ cfg.finalPackage ];
|
|
|
|
|
2022-12-29 22:36:05 +01:00
|
|
|
home.sessionVariables = mkIf cfg.defaultEditor { EDITOR = "nvim"; };
|
|
|
|
|
2024-09-20 03:47:23 -03:00
|
|
|
home.shellAliases = mkIf cfg.vimdiffAlias { vimdiff = "nvim -d"; };
|
|
|
|
|
2025-01-30 13:46:03 -06:00
|
|
|
xdg.configFile = let
|
|
|
|
hasLuaConfig = lib.hasAttr "lua" config.programs.neovim.generatedConfigs;
|
|
|
|
in lib.mkMerge (
|
|
|
|
# writes runtime
|
|
|
|
(map (x: x.runtime) pluginsNormalized) ++ [{
|
|
|
|
"nvim/init.lua" = let
|
|
|
|
luaRcContent = lib.optionalString (wrappedNeovim'.initRc != "")
|
|
|
|
"vim.cmd [[source ${
|
|
|
|
pkgs.writeText "nvim-init-home-manager.vim" wrappedNeovim'.initRc
|
|
|
|
}]]" + config.programs.neovim.extraLuaConfig
|
|
|
|
+ lib.optionalString hasLuaConfig
|
|
|
|
config.programs.neovim.generatedConfigs.lua;
|
|
|
|
in mkIf (luaRcContent != "") { text = luaRcContent; };
|
|
|
|
|
|
|
|
"nvim/coc-settings.json" = mkIf cfg.coc.enable {
|
|
|
|
source = jsonFormat.generate "coc-settings.json" cfg.coc.settings;
|
|
|
|
};
|
|
|
|
}]);
|
2021-07-26 04:40:07 +02:00
|
|
|
|
2024-10-21 17:58:46 -05:00
|
|
|
programs.neovim.finalPackage = wrappedNeovim';
|
2017-11-03 02:34:42 +09:00
|
|
|
};
|
|
|
|
}
|