nixvim: fix bug with submodule maps

This commit is contained in:
Pedro Alves 2021-11-22 14:19:29 +00:00
parent e663c69032
commit aa78a78331
2 changed files with 40 additions and 53 deletions

View file

@ -49,6 +49,10 @@
}; };
maps.normalVisualOp."ç" = ":"; maps.normalVisualOp."ç" = ":";
maps.normal."<leader>m" = {
silent = true;
action = "<cmd>make<CR>";
};
plugins.lualine = { plugins.lualine = {
enable = true; enable = true;

View file

@ -24,6 +24,7 @@ let
}; };
mapOption = types.oneOf [ types.str (types.submodule { mapOption = types.oneOf [ types.str (types.submodule {
options = {
silent = mkOption { silent = mkOption {
type = types.bool; type = types.bool;
description = "Whether this mapping should be silent. Equivalent to adding <silent> to a map."; description = "Whether this mapping should be silent. Equivalent to adding <silent> to a map.";
@ -64,6 +65,7 @@ let
type = types.str; type = types.str;
description = "The action to execute."; description = "The action to execute.";
}; };
};
}) ]; }) ];
mapOptions = mode: mkOption { mapOptions = mode: mkOption {
@ -221,26 +223,7 @@ in
local __nixvim_options = ${helpers.toLuaObject cfg.options} local __nixvim_options = ${helpers.toLuaObject cfg.options}
for k,v in pairs(__nixvim_options) do for k,v in pairs(__nixvim_options) do
-- Here we use the set command because, as of right now, neovim has vim.o[k] = v
-- no equivalent using the lua API. You have to sort through the
-- options and know which options are local to what
if type(v) == "boolean" then
local no
if v then no = "" else no = "no" end
vim.cmd("set " .. no .. k)
elseif type(v) == "table" then
local val = ""
for i,opt in ipairs(v) do
val = val .. tostring(opt)
if i ~= #v then
val = val .. ","
end
end
vim.cmd("set " .. k .. "=" .. val)
else
vim.cmd("set " .. k .. "=" .. tostring(v))
end
end end
-- }}} -- }}}
'' + optionalString (mappings != []) '' '' + optionalString (mappings != []) ''