nixos/neovim: add runtime file to etc/xdg/nvim (#221832)
Else the files in the runtime can't be accessed from the vimrc. I also remove the /etc. I thought it's a leftover of the old runtime implementation which is replaced in 307b125
.
Co-authored-by: linsui <linsui555@gmail.com>
This commit is contained in:
parent
6d9b879602
commit
7b6d5d4158
@ -4,12 +4,8 @@ with lib;
|
|||||||
|
|
||||||
let
|
let
|
||||||
cfg = config.programs.neovim;
|
cfg = config.programs.neovim;
|
||||||
|
in
|
||||||
runtime' = filter (f: f.enable) (attrValues cfg.runtime);
|
{
|
||||||
|
|
||||||
runtime = pkgs.linkFarm "neovim-runtime" (map (x: { name = "etc/${x.target}"; path = x.source; }) runtime');
|
|
||||||
|
|
||||||
in {
|
|
||||||
options.programs.neovim = {
|
options.programs.neovim = {
|
||||||
enable = mkOption {
|
enable = mkOption {
|
||||||
type = types.bool;
|
type = types.bool;
|
||||||
@ -70,7 +66,7 @@ in {
|
|||||||
|
|
||||||
configure = mkOption {
|
configure = mkOption {
|
||||||
type = types.attrs;
|
type = types.attrs;
|
||||||
default = {};
|
default = { };
|
||||||
example = literalExpression ''
|
example = literalExpression ''
|
||||||
{
|
{
|
||||||
customRC = '''
|
customRC = '''
|
||||||
@ -105,7 +101,7 @@ in {
|
|||||||
};
|
};
|
||||||
|
|
||||||
runtime = mkOption {
|
runtime = mkOption {
|
||||||
default = {};
|
default = { };
|
||||||
example = literalExpression ''
|
example = literalExpression ''
|
||||||
{ "ftplugin/c.vim".text = "setlocal omnifunc=v:lua.vim.lsp.omnifunc"; }
|
{ "ftplugin/c.vim".text = "setlocal omnifunc=v:lua.vim.lsp.omnifunc"; }
|
||||||
'';
|
'';
|
||||||
@ -115,14 +111,15 @@ in {
|
|||||||
|
|
||||||
type = with types; attrsOf (submodule (
|
type = with types; attrsOf (submodule (
|
||||||
{ name, config, ... }:
|
{ name, config, ... }:
|
||||||
{ options = {
|
{
|
||||||
|
options = {
|
||||||
|
|
||||||
enable = mkOption {
|
enable = mkOption {
|
||||||
type = types.bool;
|
type = types.bool;
|
||||||
default = true;
|
default = true;
|
||||||
description = lib.mdDoc ''
|
description = lib.mdDoc ''
|
||||||
Whether this /etc file should be generated. This
|
Whether this runtime directory should be generated. This
|
||||||
option allows specific /etc files to be disabled.
|
option allows specific runtime files to be disabled.
|
||||||
'';
|
'';
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -147,14 +144,9 @@ in {
|
|||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
config = {
|
config.target = mkDefault name;
|
||||||
target = mkDefault name;
|
}
|
||||||
source = mkIf (config.text != null) (
|
));
|
||||||
let name' = "neovim-runtime" + baseNameOf name;
|
|
||||||
in mkDefault (pkgs.writeText name' config.text));
|
|
||||||
};
|
|
||||||
|
|
||||||
}));
|
|
||||||
|
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
@ -165,14 +157,17 @@ in {
|
|||||||
];
|
];
|
||||||
environment.variables.EDITOR = mkIf cfg.defaultEditor (mkOverride 900 "nvim");
|
environment.variables.EDITOR = mkIf cfg.defaultEditor (mkOverride 900 "nvim");
|
||||||
|
|
||||||
programs.neovim.finalPackage = pkgs.wrapNeovim cfg.package {
|
environment.etc = listToAttrs (attrValues (mapAttrs
|
||||||
inherit (cfg) viAlias vimAlias withPython3 withNodeJs withRuby;
|
(name: value: {
|
||||||
configure = cfg.configure // {
|
name = "xdg/nvim/${name}";
|
||||||
|
value = value // {
|
||||||
|
target = "xdg/nvim/${value.target}";
|
||||||
|
};
|
||||||
|
})
|
||||||
|
cfg.runtime));
|
||||||
|
|
||||||
customRC = (cfg.configure.customRC or "") + ''
|
programs.neovim.finalPackage = pkgs.wrapNeovim cfg.package {
|
||||||
set runtimepath^=${runtime}/etc
|
inherit (cfg) viAlias vimAlias withPython3 withNodeJs withRuby configure;
|
||||||
'';
|
|
||||||
};
|
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user