mirror of
https://github.com/NotAShelf/neovim-flake.git
synced 2025-01-09 04:39:47 +01:00
neovim/init: merge conditionals in options set
This commit is contained in:
parent
b704a28a12
commit
356f92053c
2 changed files with 49 additions and 47 deletions
|
@ -5,6 +5,7 @@
|
||||||
}: let
|
}: let
|
||||||
inherit (lib.options) mkOption mkEnableOption literalMD;
|
inherit (lib.options) mkOption mkEnableOption literalMD;
|
||||||
inherit (lib.strings) optionalString;
|
inherit (lib.strings) optionalString;
|
||||||
|
inherit (lib.attrsets) optionalAttrs;
|
||||||
inherit (lib.types) enum bool str int either;
|
inherit (lib.types) enum bool str int either;
|
||||||
inherit (lib.generators) mkLuaInline;
|
inherit (lib.generators) mkLuaInline;
|
||||||
inherit (lib.nvim.dag) entryAfter;
|
inherit (lib.nvim.dag) entryAfter;
|
||||||
|
@ -94,55 +95,55 @@ in {
|
||||||
# Set options that were previously interpolated in 'luaConfigRC.basic' as vim.options (vim.o)
|
# Set options that were previously interpolated in 'luaConfigRC.basic' as vim.options (vim.o)
|
||||||
# and 'vim.globals' (vim.g). Future options, if possible, should be added here instead of the
|
# and 'vim.globals' (vim.g). Future options, if possible, should be added here instead of the
|
||||||
# luaConfigRC section below.
|
# luaConfigRC section below.
|
||||||
options = pushDownDefault {
|
options = pushDownDefault (lib.mergeAttrsList [
|
||||||
# Options that are always set, with a lower priority
|
{
|
||||||
encoding = "utf-8";
|
# Options that are always set, with a lower priority
|
||||||
hidden = true;
|
encoding = "utf-8";
|
||||||
expandtab = true;
|
hidden = true;
|
||||||
|
expandtab = true;
|
||||||
|
|
||||||
# Junkfile Behaviour
|
# Junkfile Behaviour
|
||||||
swapfile = !cfg.preventJunkFiles;
|
swapfile = !cfg.preventJunkFiles;
|
||||||
backup = !cfg.preventJunkFiles;
|
backup = !cfg.preventJunkFiles;
|
||||||
writebackup = !cfg.preventJunkFiles;
|
writebackup = !cfg.preventJunkFiles;
|
||||||
};
|
}
|
||||||
|
|
||||||
# Options that are more difficult to set through 'vim.options'. Fear not, though
|
(optionalAttrs cfg.undoFile.enable {
|
||||||
# as the Lua DAG is still as powerful as it could be.
|
undofile = true;
|
||||||
|
undodir = cfg.undoFile.path;
|
||||||
|
})
|
||||||
|
|
||||||
|
(optionalAttrs (cfg.bell == "none") {
|
||||||
|
errorbells = false;
|
||||||
|
visualbell = false;
|
||||||
|
})
|
||||||
|
|
||||||
|
(optionalAttrs (cfg.bell == "on") {
|
||||||
|
visualbell = false;
|
||||||
|
})
|
||||||
|
|
||||||
|
(optionalAttrs (cfg.bell == "visual") {
|
||||||
|
visualbell = false;
|
||||||
|
})
|
||||||
|
|
||||||
|
(optionalAttrs (cfg.lineNumberMode == "relative") {
|
||||||
|
relativenumber = true;
|
||||||
|
})
|
||||||
|
|
||||||
|
(optionalAttrs (cfg.lineNumberMode == "number") {
|
||||||
|
number = true;
|
||||||
|
})
|
||||||
|
|
||||||
|
(optionalAttrs (cfg.lineNumberMode == "relNumber") {
|
||||||
|
number = true;
|
||||||
|
relativenumber = true;
|
||||||
|
})
|
||||||
|
]);
|
||||||
|
|
||||||
|
# Options that are more difficult to set through 'vim.options'. Namely, appending values
|
||||||
|
# to pre-set Neovim options. Fear not, though as the Lua DAG is still as powerful as it
|
||||||
|
# could be.
|
||||||
luaConfigRC.basic = entryAfter ["globalsScript"] ''
|
luaConfigRC.basic = entryAfter ["globalsScript"] ''
|
||||||
-- Settings that are set for everything
|
|
||||||
vim.opt.shortmess:append("c")
|
|
||||||
|
|
||||||
${optionalString cfg.undoFile.enable ''
|
|
||||||
vim.o.undofile = true
|
|
||||||
vim.o.undodir = ${toLuaObject cfg.undoFile.path}
|
|
||||||
''}
|
|
||||||
|
|
||||||
${optionalString (cfg.bell == "none") ''
|
|
||||||
vim.o.errorbells = false
|
|
||||||
vim.o.visualbell = false
|
|
||||||
''}
|
|
||||||
|
|
||||||
${optionalString (cfg.bell == "on") ''
|
|
||||||
vim.o.visualbell = false
|
|
||||||
''}
|
|
||||||
|
|
||||||
${optionalString (cfg.bell == "visual") ''
|
|
||||||
vim.o.errorbells = false
|
|
||||||
''}
|
|
||||||
|
|
||||||
${optionalString (cfg.lineNumberMode == "relative") ''
|
|
||||||
vim.o.relativenumber = true
|
|
||||||
''}
|
|
||||||
|
|
||||||
${optionalString (cfg.lineNumberMode == "number") ''
|
|
||||||
vim.o.number = true
|
|
||||||
''}
|
|
||||||
|
|
||||||
${optionalString (cfg.lineNumberMode == "relNumber") ''
|
|
||||||
vim.o.number = true
|
|
||||||
vim.o.relativenumber = true
|
|
||||||
''}
|
|
||||||
|
|
||||||
${optionalString cfg.useSystemClipboard ''
|
${optionalString cfg.useSystemClipboard ''
|
||||||
vim.opt.clipboard:append("unnamedplus")
|
vim.opt.clipboard:append("unnamedplus")
|
||||||
''}
|
''}
|
||||||
|
|
|
@ -235,7 +235,8 @@ in {
|
||||||
if isBool x
|
if isBool x
|
||||||
then toVimBool x # convert to a yes/no str
|
then toVimBool x # convert to a yes/no str
|
||||||
else x;
|
else x;
|
||||||
description = "Show the sign column"
|
description = "Show the sign column";
|
||||||
|
};
|
||||||
|
|
||||||
tabstop = mkOption {
|
tabstop = mkOption {
|
||||||
type = int;
|
type = int;
|
||||||
|
|
Loading…
Reference in a new issue