mirror of
https://github.com/nix-community/nixvim.git
synced 2025-06-21 08:35:43 +02:00
bugfix: fix #17
This commit is contained in:
parent
d934a33ab5
commit
c298e98002
1 changed files with 137 additions and 130 deletions
39
nixvim.nix
39
nixvim.nix
|
@ -1,5 +1,5 @@
|
||||||
{ nixos ? false, nixOnDroid ? false, homeManager ? false }:
|
{ nixos ? false, nixOnDroid ? false, homeManager ? false }:
|
||||||
{ pkgs , lib, config, ... }:
|
{ pkgs, lib, config, ... }:
|
||||||
with lib;
|
with lib;
|
||||||
let
|
let
|
||||||
cfg = config.programs.nixvim;
|
cfg = config.programs.nixvim;
|
||||||
|
@ -23,7 +23,9 @@ let
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
mapOption = types.oneOf [ types.str (types.submodule {
|
mapOption = types.oneOf [
|
||||||
|
types.str
|
||||||
|
(types.submodule {
|
||||||
options = {
|
options = {
|
||||||
silent = mkOption {
|
silent = mkOption {
|
||||||
type = types.bool;
|
type = types.bool;
|
||||||
|
@ -72,12 +74,13 @@ let
|
||||||
default = null;
|
default = null;
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
}) ];
|
})
|
||||||
|
];
|
||||||
|
|
||||||
mapOptions = mode: mkOption {
|
mapOptions = mode: mkOption {
|
||||||
description = "Mappings for ${mode} mode";
|
description = "Mappings for ${mode} mode";
|
||||||
type = types.attrsOf mapOption;
|
type = types.attrsOf mapOption;
|
||||||
default = {};
|
default = { };
|
||||||
};
|
};
|
||||||
|
|
||||||
helpers = import ./plugins/helpers.nix { lib = lib; };
|
helpers = import ./plugins/helpers.nix { lib = lib; };
|
||||||
|
@ -183,13 +186,14 @@ in
|
||||||
./plugins
|
./plugins
|
||||||
];
|
];
|
||||||
|
|
||||||
config = let
|
config =
|
||||||
|
let
|
||||||
neovimConfig = pkgs.neovimUtils.makeNeovimConfig {
|
neovimConfig = pkgs.neovimUtils.makeNeovimConfig {
|
||||||
configure = cfg.configure;
|
configure = cfg.configure;
|
||||||
plugins = cfg.extraPlugins;
|
plugins = cfg.extraPlugins;
|
||||||
};
|
};
|
||||||
|
|
||||||
extraWrapperArgs = optionalString (cfg.extraPackages != [])
|
extraWrapperArgs = optionalString (cfg.extraPackages != [ ])
|
||||||
''--prefix PATH : "${makeBinPath cfg.extraPackages}"'';
|
''--prefix PATH : "${makeBinPath cfg.extraPackages}"'';
|
||||||
|
|
||||||
package = if (cfg.package != null) then cfg.package else pkgs.neovim;
|
package = if (cfg.package != null) then cfg.package else pkgs.neovim;
|
||||||
|
@ -209,16 +213,17 @@ in
|
||||||
'';
|
'';
|
||||||
|
|
||||||
packages.nixvim = {
|
packages.nixvim = {
|
||||||
start = filter (f: f != null) (map (x:
|
start = filter (f: f != null) (map
|
||||||
|
(x:
|
||||||
if x ? plugin && x.optional == true then null else (x.plugin or x))
|
if x ? plugin && x.optional == true then null else (x.plugin or x))
|
||||||
cfg.extraPlugins);
|
cfg.extraPlugins);
|
||||||
opt = filter (f: f!= null)
|
opt = filter (f: f != null)
|
||||||
(map (x: if x ? plugin && x.optional == true then x.plugin else null)
|
(map (x: if x ? plugin && x.optional == true then x.plugin else null)
|
||||||
cfg.extraPlugins);
|
cfg.extraPlugins);
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
extraConfigLua = optionalString (cfg.globals != {}) ''
|
extraConfigLua = optionalString (cfg.globals != { }) ''
|
||||||
-- Set up globals {{{
|
-- Set up globals {{{
|
||||||
local __nixvim_globals = ${helpers.toLuaObject cfg.globals}
|
local __nixvim_globals = ${helpers.toLuaObject cfg.globals}
|
||||||
|
|
||||||
|
@ -226,7 +231,7 @@ in
|
||||||
vim.g[k] = v
|
vim.g[k] = v
|
||||||
end
|
end
|
||||||
-- }}}
|
-- }}}
|
||||||
'' + optionalString (cfg.options != {}) ''
|
'' + optionalString (cfg.options != { }) ''
|
||||||
-- Set up options {{{
|
-- Set up options {{{
|
||||||
local __nixvim_options = ${helpers.toLuaObject cfg.options}
|
local __nixvim_options = ${helpers.toLuaObject cfg.options}
|
||||||
|
|
||||||
|
@ -234,7 +239,7 @@ in
|
||||||
vim.o[k] = v
|
vim.o[k] = v
|
||||||
end
|
end
|
||||||
-- }}}
|
-- }}}
|
||||||
'' + optionalString (mappings != []) ''
|
'' + optionalString (mappings != [ ]) ''
|
||||||
-- Set up keybinds {{{
|
-- Set up keybinds {{{
|
||||||
local __nixvim_binds = ${helpers.toLuaObject mappings}
|
local __nixvim_binds = ${helpers.toLuaObject mappings}
|
||||||
|
|
||||||
|
@ -257,16 +262,18 @@ in
|
||||||
(helpers.genMaps "!" cfg.maps.insertCommand) ++
|
(helpers.genMaps "!" cfg.maps.insertCommand) ++
|
||||||
(helpers.genMaps "c" cfg.maps.command);
|
(helpers.genMaps "c" cfg.maps.command);
|
||||||
|
|
||||||
in mkIf cfg.enable (if nixos then {
|
in
|
||||||
|
mkIf cfg.enable (if nixos then {
|
||||||
environment.systemPackages = [ wrappedNeovim ];
|
environment.systemPackages = [ wrappedNeovim ];
|
||||||
programs.neovim = {
|
programs.neovim = {
|
||||||
configure = configure;
|
configure = configure;
|
||||||
|
|
||||||
extraConfigLua = extraConfigLua;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
programs.nixvim.extraConfigLua = extraConfigLua;
|
||||||
|
|
||||||
environment.etc."xdg/nvim/sysinit.vim".text = neovimConfig.neovimRcContent;
|
environment.etc."xdg/nvim/sysinit.vim".text = neovimConfig.neovimRcContent;
|
||||||
} else (if homeManager then {
|
} else
|
||||||
|
(if homeManager then {
|
||||||
programs.nixvim.extraConfigLua = extraConfigLua;
|
programs.nixvim.extraConfigLua = extraConfigLua;
|
||||||
programs.neovim = {
|
programs.neovim = {
|
||||||
enable = true;
|
enable = true;
|
||||||
|
@ -275,5 +282,5 @@ in
|
||||||
extraConfig = configure.customRC;
|
extraConfig = configure.customRC;
|
||||||
plugins = cfg.extraPlugins;
|
plugins = cfg.extraPlugins;
|
||||||
};
|
};
|
||||||
} else {}));
|
} else { }));
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue