From db76167e95113a1c3ba9b2694376a4fef82068af Mon Sep 17 00:00:00 2001 From: Pei Yang Ching <59727193+horriblename@users.noreply.github.com> Date: Sat, 24 Aug 2024 15:54:25 +0200 Subject: [PATCH] lazy: move type definition out of lib --- configuration.nix | 9 - flake.lock | 34 ---- flake.nix | 11 -- lib/binds.nix | 17 -- lib/types/default.nix | 2 +- lib/types/plugins.nix | 195 +------------------ modules/default.nix | 5 +- modules/modules.nix | 1 - modules/neovim/mappings/config.nix | 89 +++------ modules/neovim/mappings/options.nix | 65 +++---- modules/plugins/filetree/nvimtree/config.nix | 36 ++-- modules/plugins/theme/supported-themes.nix | 4 +- modules/wrapper/lazy/config.nix | 85 -------- modules/wrapper/lazy/default.nix | 6 - modules/wrapper/lazy/lazy.nix | 29 --- modules/wrapper/rc/config.nix | 43 +++- 16 files changed, 113 insertions(+), 518 deletions(-) delete mode 100644 modules/wrapper/lazy/config.nix delete mode 100644 modules/wrapper/lazy/default.nix delete mode 100644 modules/wrapper/lazy/lazy.nix diff --git a/configuration.nix b/configuration.nix index 24b4630..b0c613b 100644 --- a/configuration.nix +++ b/configuration.nix @@ -8,15 +8,6 @@ isMaximal: { logFile = "/tmp/nvim.log"; }; - lazy = { - plugins = [ - { - package = "vim-repeat"; - keys = "."; - } - ]; - }; - spellcheck = { enable = isMaximal; }; diff --git a/flake.lock b/flake.lock index 79458df..3fcb387 100644 --- a/flake.lock +++ b/flake.lock @@ -843,38 +843,6 @@ "type": "github" } }, - "plugin-lz-n": { - "flake": false, - "locked": { - "lastModified": 1724402266, - "narHash": "sha256-JLCJPiRUt0RFDR/WYZMjkm/keaDo+QNwTII2GyiDAhk=", - "owner": "nvim-neorocks", - "repo": "lz.n", - "rev": "fc67ba432830f499c0afadd35f2942c8620aaf1a", - "type": "github" - }, - "original": { - "owner": "nvim-neorocks", - "repo": "lz.n", - "type": "github" - } - }, - "plugin-lzn-auto-require": { - "flake": false, - "locked": { - "lastModified": 1724239920, - "narHash": "sha256-wNtja4vbfzgVwVh8fw6cfTHxcxPOqr6z4nl5Fjj2d0I=", - "owner": "horriblename", - "repo": "lzn-auto-require", - "rev": "c74fa9be2203438aab7fd132310abdb181426c66", - "type": "github" - }, - "original": { - "owner": "horriblename", - "repo": "lzn-auto-require", - "type": "github" - } - }, "plugin-mind-nvim": { "flake": false, "locked": { @@ -1904,8 +1872,6 @@ "plugin-lspkind": "plugin-lspkind", "plugin-lspsaga": "plugin-lspsaga", "plugin-lualine": "plugin-lualine", - "plugin-lz-n": "plugin-lz-n", - "plugin-lzn-auto-require": "plugin-lzn-auto-require", "plugin-mind-nvim": "plugin-mind-nvim", "plugin-minimap-vim": "plugin-minimap-vim", "plugin-modes-nvim": "plugin-modes-nvim", diff --git a/flake.nix b/flake.nix index 8468bd2..c00e9b8 100644 --- a/flake.nix +++ b/flake.nix @@ -102,17 +102,6 @@ }; ## Plugins - # Lazy loading - plugin-lz-n = { - url = "github:nvim-neorocks/lz.n"; - flake = false; - }; - - plugin-lzn-auto-require = { - url = "github:horriblename/lzn-auto-require"; - flake = false; - }; - # LSP plugins plugin-nvim-lspconfig = { url = "github:neovim/nvim-lspconfig"; diff --git a/lib/binds.nix b/lib/binds.nix index ca187f2..8c9e9a6 100644 --- a/lib/binds.nix +++ b/lib/binds.nix @@ -67,23 +67,6 @@ mkLuaBinding binding.value action binding.description; pushDownDefault = attr: mapAttrs (_: mkDefault) attr; - - mkLznBinding = mode: key: action: desc: { - inherit mode desc key action; - }; - - mkSetLznBinding = binding: action: { - inherit action; - key = binding.value; - desc = binding.description; - }; - - mkSetLuaLznBinding = binding: action: { - inherit action; - key = binding.value; - lua = true; - desc = binding.description; - }; }; in binds diff --git a/lib/types/default.nix b/lib/types/default.nix index 170667d..928bbae 100644 --- a/lib/types/default.nix +++ b/lib/types/default.nix @@ -9,7 +9,7 @@ typesCustom = import ./custom.nix {inherit lib;}; in { inherit (typesDag) dagOf; - inherit (typesPlugin) pluginsOpt extraPluginType mkPluginSetupOption luaInline pluginType lznPluginType lznPluginTableType; + inherit (typesPlugin) pluginsOpt extraPluginType mkPluginSetupOption luaInline pluginType; inherit (typesLanguage) diagnostics mkGrammarOption; inherit (typesCustom) anythingConcatLists char; } diff --git a/lib/types/plugins.nix b/lib/types/plugins.nix index 8532772..c0e89d6 100644 --- a/lib/types/plugins.nix +++ b/lib/types/plugins.nix @@ -6,7 +6,8 @@ inherit (lib.options) mkOption; inherit (lib.attrsets) attrNames mapAttrs' filterAttrs nameValuePair; inherit (lib.strings) hasPrefix removePrefix; - inherit (lib.types) submodule either package enum str lines attrsOf anything listOf nullOr oneOf bool int; + inherit (lib.types) submodule either package enum str lines attrsOf anything listOf nullOr; + # Get the names of all flake inputs that start with the given prefix. fromInputs = { inputs, @@ -50,193 +51,8 @@ }; }; }; - - luaInline = lib.mkOptionType { - name = "luaInline"; - check = x: lib.nvim.lua.isLuaInline x; - }; - - lznKeysSpec = submodule { - options = { - desc = mkOption { - description = "Description of the key map"; - type = nullOr str; - default = null; - }; - - noremap = mkOption { - description = "TBD"; - type = bool; - default = false; - }; - - expr = mkOption { - description = "TBD"; - type = bool; - default = false; - }; - - nowait = mkOption { - description = "TBD"; - type = bool; - default = false; - }; - - ft = mkOption { - description = "TBD"; - type = nullOr (listOf str); - default = null; - }; - - key = mkOption { - type = str; - description = "Key to bind to"; - }; - - action = mkOption { - type = nullOr str; - default = null; - description = "Action to trigger."; - }; - - lua = mkOption { - type = bool; - default = false; - description = "If true the action is treated as a lua function instead of a vim command."; - }; - - mode = mkOption { - description = "Modes to bind in"; - type = listOf str; - default = ["n" "x" "s" "o"]; - }; - }; - }; - - lznPluginTableType = attrsOf lznPluginType; - lznPluginType = submodule { - options = { - ## Should probably infer from the actual plugin somehow - ## In general this is the name passed to packadd, so the dir name of the plugin - # name = mkOption { - # type= str; - # } - - # Non-lz.n options - - package = mkOption { - type = pluginType; - description = "Plugin package"; - }; - - setupModule = mkOption { - type = nullOr str; - description = "Lua module to run setup function on."; - default = null; - }; - - setupOpts = mkOption { - type = submodule {freeformType = attrsOf anything;}; - description = "Options to pass to the setup function"; - default = {}; - }; - - # lz.n options - - enabled = mkOption { - type = nullOr (either bool str); - description = "When false, or if the lua function returns false, this plugin will not be included in the spec"; - default = null; - }; - - beforeAll = mkOption { - type = nullOr str; - description = "Lua code to run before any plugins are loaded. This will be wrapped in a function."; - default = null; - }; - - before = mkOption { - type = nullOr str; - description = "Lua code to run before plugin is loaded. This will be wrapped in a function."; - default = null; - }; - - after = mkOption { - type = nullOr str; - description = "Lua code to run after plugin is loaded. This will be wrapped in a function."; - default = null; - }; - - event = mkOption { - description = "Lazy-load on event"; - default = null; - type = let - event = submodule { - options = { - event = mkOption { - type = nullOr (either str (listOf str)); - description = "Exact event name"; - example = "BufEnter"; - }; - pattern = mkOption { - type = nullOr (either str (listOf str)); - description = "Event pattern"; - example = "BufEnter *.lua"; - }; - }; - }; - in - nullOr (oneOf [str (listOf str) event]); - }; - - cmd = mkOption { - description = "Lazy-load on command"; - default = null; - type = nullOr (either str (listOf str)); - }; - - ft = mkOption { - description = "Lazy-load on filetype"; - default = null; - type = nullOr (either str (listOf str)); - }; - - keys = mkOption { - description = "Lazy-load on key mapping"; - default = null; - type = nullOr (oneOf [str (listOf lznKeysSpec) (listOf str)]); - example = '' - keys = [ - {lhs = "s"; rhs = ":NvimTreeToggle"; desc = "Toggle NvimTree"} - ] - ''; - }; - - colorscheme = mkOption { - description = "Lazy-load on colorscheme."; - type = nullOr (either str (listOf str)); - default = null; - }; - - priority = mkOption { - type = nullOr int; - description = "Only useful for stat plugins (not lazy-loaded) to force loading certain plugins first."; - default = null; - }; - - load = mkOption { - type = nullOr str; - default = null; - description = '' - Lua code to override the `vim.g.lz_n.load()` function for a single plugin. - - This will be wrapped in a function - ''; - }; - }; - }; in { - inherit extraPluginType fromInputs pluginType luaInline lznPluginType lznPluginTableType; + inherit extraPluginType fromInputs pluginType; pluginsOpt = { description, @@ -248,6 +64,11 @@ in { type = pluginsType; }; + luaInline = lib.mkOptionType { + name = "luaInline"; + check = x: lib.nvim.lua.isLuaInline x; + }; + /* opts is a attrset of options, example: ``` diff --git a/modules/default.nix b/modules/default.nix index 8a436d5..1ae3b03 100644 --- a/modules/default.nix +++ b/modules/default.nix @@ -69,7 +69,10 @@ inputs: { # built (or "normalized") plugins that are modified builtStartPlugins = buildConfigPlugins vimOptions.startPlugins; - builtOptPlugins = map (package: package // {optional = true;}) (buildConfigPlugins vimOptions.optPlugins); + builtOptPlugins = map (package: { + plugin = package; + optional = true; + }) (buildConfigPlugins vimOptions.optPlugins); # additional Lua and Python3 packages, mapped to their respective functions # to conform to the format mnw expects. end user should diff --git a/modules/modules.nix b/modules/modules.nix index a995754..a00cea6 100644 --- a/modules/modules.nix +++ b/modules/modules.nix @@ -50,7 +50,6 @@ wrapper = map (p: ./wrapper + "/${p}") [ "build" "rc" - "lazy" "warnings" ]; diff --git a/modules/neovim/mappings/config.nix b/modules/neovim/mappings/config.nix index 4d7f241..365e124 100644 --- a/modules/neovim/mappings/config.nix +++ b/modules/neovim/mappings/config.nix @@ -3,75 +3,32 @@ lib, ... }: let - inherit (lib.modules) mkIf mkMerge; - inherit (lib.trivial) pipe; - inherit (lib.attrsets) mapAttrsToList; - inherit (lib.lists) flatten; - - legacyMapModes = { - normal = ["n"]; - insert = ["i"]; - select = ["s"]; - visual = ["v"]; - terminal = ["t"]; - normalVisualOp = ["n" "v" "o"]; - visualOnly = ["n" "x"]; - operator = ["o"]; - insertCommand = ["i" "c"]; - lang = ["l"]; - command = ["c"]; - }; + inherit (lib.modules) mkIf; cfg = config.vim; in { config = { - vim.keymaps = mkMerge [ - ( - mkIf cfg.disableArrows [ - { - key = ""; - mode = ["n" "i"]; - action = ""; - noremap = false; - } - { - key = ""; - mode = ["n" "i"]; - action = ""; - noremap = false; - } - { - key = ""; - mode = ["n" "i"]; - action = ""; - noremap = false; - } - { - key = ""; - mode = ["n" "i"]; - action = ""; - noremap = false; - } - ] - ) - ( - pipe cfg.maps - [ - (mapAttrsToList ( - oldMode: keybinds: - mapAttrsToList ( - key: bind: - bind - // { - inherit key; - mode = legacyMapModes.${oldMode}; - } - ) - keybinds - )) - flatten - ] - ) - ]; + vim.maps = mkIf cfg.disableArrows { + "" = { + mode = ["n" "i"]; + action = ""; + noremap = false; + }; + "" = { + mode = ["n" "i"]; + action = ""; + noremap = false; + }; + "" = { + mode = ["n" "i"]; + action = ""; + noremap = false; + }; + "" = { + mode = ["n" "i"]; + action = ""; + noremap = false; + }; + }; }; } diff --git a/modules/neovim/mappings/options.nix b/modules/neovim/mappings/options.nix index 49e7249..f422991 100644 --- a/modules/neovim/mappings/options.nix +++ b/modules/neovim/mappings/options.nix @@ -31,12 +31,6 @@ options = mapConfigOptions // { - key = mkOption { - type = str; - description = '' - Key that triggers this keybind. - ''; - }; mode = mkOption { type = either str (listOf str); description = '' @@ -44,59 +38,52 @@ See `:help map-modes` for a list of modes. ''; - example = ''"nvc" for normal, visual and command mode''; }; }; }; # legacy stuff - legacyMapOption = submodule { + mapOption = submodule { options = mapConfigOptions; }; mapOptions = mode: mkOption { description = "Mappings for ${mode} mode"; - type = attrsOf legacyMapOption; + type = attrsOf mapOption; default = {}; }; in { options.vim = { - keymaps = mkOption { - type = listOf mapType; + maps = mkOption { + type = submodule { + freeformType = attrsOf mapType; + options = { + normal = mapOptions "normal"; + insert = mapOptions "insert"; + select = mapOptions "select"; + visual = mapOptions "visual and select"; + terminal = mapOptions "terminal"; + normalVisualOp = mapOptions "normal, visual, select and operator-pending (same as plain 'map')"; + + visualOnly = mapOptions "visual only"; + operator = mapOptions "operator-pending"; + insertCommand = mapOptions "insert and command-line"; + lang = mapOptions "insert, command-line and lang-arg"; + command = mapOptions "command-line"; + }; + }; + default = {}; description = "Custom keybindings."; example = '' - vim.keymaps = [ - { - key = "m"; + maps = { + "m" = { mode = "n"; silent = true; - action = ":make"; - } - { - key = "l"; - mode = ["n" "x"]; - silent = true; - action = "cnext"; - } - ]; + action = "make"; + }; # Same as nnoremap m make + }; ''; - default = {}; - }; - - maps = { - normal = mapOptions "normal"; - insert = mapOptions "insert"; - select = mapOptions "select"; - visual = mapOptions "visual and select"; - terminal = mapOptions "terminal"; - normalVisualOp = mapOptions "normal, visual, select and operator-pending (same as plain 'map')"; - - visualOnly = mapOptions "visual only"; - operator = mapOptions "operator-pending"; - insertCommand = mapOptions "insert and command-line"; - lang = mapOptions "insert, command-line and lang-arg"; - command = mapOptions "command-line"; }; }; } diff --git a/modules/plugins/filetree/nvimtree/config.nix b/modules/plugins/filetree/nvimtree/config.nix index a2f9811..b97b1e4 100644 --- a/modules/plugins/filetree/nvimtree/config.nix +++ b/modules/plugins/filetree/nvimtree/config.nix @@ -4,11 +4,11 @@ pkgs, ... }: let - inherit (builtins) filter; inherit (lib.strings) optionalString; - inherit (lib.modules) mkIf; - inherit (lib.nvim.binds) mkLznBinding; + inherit (lib.modules) mkIf mkMerge; + inherit (lib.nvim.binds) mkBinding; inherit (lib.nvim.dag) entryAnywhere; + inherit (lib.nvim.lua) toLuaObject; inherit (lib.nvim.binds) pushDownDefault; cfg = config.vim.filetree.nvimTree; @@ -16,28 +16,19 @@ inherit (self.options.vim.filetree.nvimTree) mappings; in { config = mkIf cfg.enable { + vim.startPlugins = ["nvim-tree-lua"]; + + vim.maps.normal = mkMerge [ + (mkBinding cfg.mappings.toggle ":NvimTreeToggle" mappings.toggle.description) + (mkBinding cfg.mappings.refresh ":NvimTreeRefresh" mappings.refresh.description) + (mkBinding cfg.mappings.findFile ":NvimTreeFindFile" mappings.findFile.description) + (mkBinding cfg.mappings.focus ":NvimTreeFocus" mappings.focus.description) + ]; + vim.binds.whichKey.register = pushDownDefault { "t" = "+NvimTree"; }; - vim.lazy = { - plugins = [ - { - package = "nvim-tree-lua"; - setupModule = "nvim-tree"; - inherit (cfg) setupOpts; - cmd = ["NvimTreeClipboard" "NvimTreeClose" "NvimTreeCollapse" "NvimTreeCollapseKeepBuffers" "NvimTreeFindFile" "NvimTreeFindFileToggle" "NvimTreeFocus" "NvimTreeHiTest" "NvimTreeOpen" "NvimTreeRefresh" "NvimTreeResize" "NvimTreeToggle"]; - - keys = filter ({key, ...}: key != null) [ - (mkLznBinding ["n"] cfg.mappings.toggle ":NvimTreeToggle" mappings.toggle.description) - (mkLznBinding ["n"] cfg.mappings.refresh ":NvimTreeRefresh" mappings.refresh.description) - (mkLznBinding ["n"] cfg.mappings.findFile ":NvimTreeFindFile" mappings.findFile.description) - (mkLznBinding ["n"] cfg.mappings.focus ":NvimTreeFocus" mappings.focus.description) - ]; - } - ]; - }; - vim.pluginRC.nvimtreelua = entryAnywhere '' ${ optionalString cfg.setupOpts.disable_netrw '' @@ -47,9 +38,10 @@ in { '' } + require'nvim-tree'.setup(${toLuaObject cfg.setupOpts}) + ${ optionalString cfg.openOnSetup '' - require('lz.n').trigger_load("nvim-tree-lua") -- autostart behaviour -- Open on startup has been deprecated -- see https://github.com/nvim-tree/nvim-tree.lua/wiki/Open-At-Startup diff --git a/modules/plugins/theme/supported-themes.nix b/modules/plugins/theme/supported-themes.nix index 6d992c4..63335e4 100644 --- a/modules/plugins/theme/supported-themes.nix +++ b/modules/plugins/theme/supported-themes.nix @@ -6,7 +6,7 @@ inherit (lib.trivial) boolToString warnIf; in { onedark = { - setup = {style ? "dark"}: '' + setup = {style ? "dark", ...}: '' -- OneDark theme require('onedark').setup { style = "${style}" @@ -30,7 +30,7 @@ in { }; dracula = { - setup = {transparent}: '' + setup = {transparent, ...}: '' require('dracula').setup({ transparent_bg = ${boolToString transparent}, }); diff --git a/modules/wrapper/lazy/config.nix b/modules/wrapper/lazy/config.nix deleted file mode 100644 index 3965083..0000000 --- a/modules/wrapper/lazy/config.nix +++ /dev/null @@ -1,85 +0,0 @@ -{ - lib, - config, - ... -}: let - inherit (builtins) toJSON typeOf head length tryEval; - inherit (lib.modules) mkIf; - inherit (lib.attrsets) mapAttrsToList; - inherit (lib.generators) mkLuaInline; - inherit (lib.strings) optionalString; - inherit (lib.nvim.lua) toLuaObject; - inherit (lib.nvim.dag) entryBefore; - cfg = config.vim.lazy; - - toLuzLznKeySpec = { - desc, - noremap, - expr, - nowait, - ft, - key, - action, - lua, - mode, - }: { - "@1" = key; - "@2" = - if lua - then mkLuaInline action - else action; - inherit desc noremap expr nowait ft mode; - }; - - toLuaLznSpec = spec: let - name = - if typeOf spec.package == "string" - then spec.package - else if (spec.package ? pname && (tryEval spec.package.pname).success) - then spec.package.pname - else spec.package.name; - in - (removeAttrs spec ["package" "setupModule" "setupOpts" "keys"]) - // { - "@1" = name; - before = - if spec.before != null - then - mkLuaInline '' - function() - ${spec.before} - end - '' - else null; - - after = - if spec.setupModule == null && spec.after == null - then null - else - mkLuaInline '' - function() - ${ - optionalString (spec.setupModule != null) - "require(${toJSON spec.setupModule}).setup(${toLuaObject spec.setupOpts})" - } - ${optionalString (spec.after != null) spec.after} - end - ''; - - keys = - if typeOf spec.keys == "list" && length spec.keys > 0 && typeOf (head spec.keys) == "set" - then map toLuzLznKeySpec spec.keys - else spec.keys; - }; - lznSpecs = map toLuaLznSpec cfg.plugins; -in { - config.vim = mkIf cfg.enable { - startPlugins = ["lz-n" "lzn-auto-require"]; - - optPlugins = map (plugin: plugin.package) cfg.plugins; - - luaConfigRC.lzn-load = entryBefore ["pluginConfigs"] '' - require('lz.n').load(${toLuaObject lznSpecs}) - ''; - }; -} diff --git a/modules/wrapper/lazy/default.nix b/modules/wrapper/lazy/default.nix deleted file mode 100644 index fa40127..0000000 --- a/modules/wrapper/lazy/default.nix +++ /dev/null @@ -1,6 +0,0 @@ -_: { - imports = [ - ./lazy.nix - ./config.nix - ]; -} diff --git a/modules/wrapper/lazy/lazy.nix b/modules/wrapper/lazy/lazy.nix deleted file mode 100644 index 77502d4..0000000 --- a/modules/wrapper/lazy/lazy.nix +++ /dev/null @@ -1,29 +0,0 @@ -{lib, ...}: let - inherit (lib.options) mkOption mkEnableOption; - inherit (lib.types) enum listOf; - inherit (lib.nvim.types) lznPluginType; -in { - options.vim.lazy = { - enable = mkEnableOption "plugin lazy-loading" // {default = true;}; - loader = mkOption { - description = "Lazy loader to use"; - type = enum ["lz.n"]; - default = "lz.n"; - }; - - plugins = mkOption { - default = []; - type = listOf lznPluginType; - description = "list of plugins to lazy load"; - example = '' - [ - { - package = "toggleterm-nvim"; - after = lib.generators.mkLuaInline "function() require('toggleterm').setup{} end"; - cmd = ["ToggleTerm"]; - } - ] - ''; - }; - }; -} diff --git a/modules/wrapper/rc/config.nix b/modules/wrapper/rc/config.nix index 5662b65..b3fd2e4 100644 --- a/modules/wrapper/rc/config.nix +++ b/modules/wrapper/rc/config.nix @@ -3,9 +3,9 @@ lib, ... }: let - inherit (builtins) map mapAttrs filter; - inherit (lib.attrsets) mapAttrsToList filterAttrs; - inherit (lib.strings) concatLines concatMapStringsSep optionalString; + inherit (builtins) map mapAttrs filter removeAttrs attrNames; + inherit (lib.attrsets) mapAttrsToList filterAttrs attrsToList; + inherit (lib.strings) concatLines concatMapStringsSep; inherit (lib.trivial) showWarnings; inherit (lib.generators) mkLuaInline; inherit (lib.nvim.dag) entryAfter mkLuarcSection resolveDag entryAnywhere; @@ -40,11 +40,40 @@ in { inherit (keymap) desc silent nowait script expr unique noremap; }; - toLuaKeymap = bind: "vim.keymap.set(${toLuaObject bind.mode}, ${toLuaObject bind.key}, ${toLuaObject (getAction bind)}, ${toLuaObject (getOpts bind)})"; + toLuaKeymap = { + name, + value, + }: "vim.keymap.set(${toLuaObject value.mode}, ${toLuaObject name}, ${toLuaObject (getAction value)}, ${toLuaObject (getOpts value)})"; - maps = concatLines (map toLuaKeymap cfg.keymaps); + namedModes = { + "normal" = ["n"]; + "insert" = ["i"]; + "select" = ["s"]; + "visual" = ["v"]; + "terminal" = ["t"]; + "normalVisualOp" = ["n" "v" "o"]; + "visualOnly" = ["n" "x"]; + "operator" = ["o"]; + "insertCommand" = ["i" "c"]; + "lang" = ["l"]; + "command" = ["c"]; + }; - keymaps = maps; + maps = + removeAttrs cfg.maps (attrNames namedModes) + // mapAttrs (_: legacyMap: legacyMap // {mode = namedModes.normal;}) cfg.maps.normal + // mapAttrs (_: legacyMap: legacyMap // {mode = namedModes.insert;}) cfg.maps.insert + // mapAttrs (_: legacyMap: legacyMap // {mode = namedModes.select;}) cfg.maps.select + // mapAttrs (_: legacyMap: legacyMap // {mode = namedModes.visual;}) cfg.maps.visual + // mapAttrs (_: legacyMap: legacyMap // {mode = namedModes.terminal;}) cfg.maps.terminal + // mapAttrs (_: legacyMap: legacyMap // {mode = namedModes.normalVisualOp;}) cfg.maps.normalVisualOp + // mapAttrs (_: legacyMap: legacyMap // {mode = namedModes.visualOnly;}) cfg.maps.visualOnly + // mapAttrs (_: legacyMap: legacyMap // {mode = namedModes.operator;}) cfg.maps.operator + // mapAttrs (_: legacyMap: legacyMap // {mode = namedModes.insertCommand;}) cfg.maps.insertCommand + // mapAttrs (_: legacyMap: legacyMap // {mode = namedModes.lang;}) cfg.maps.lang + // mapAttrs (_: legacyMap: legacyMap // {mode = namedModes.command;}) cfg.maps.command; + + keymaps = concatLines (map toLuaKeymap (attrsToList (filterNonNull maps))); in { vim = { luaConfigRC = { @@ -53,8 +82,6 @@ in { pluginConfigs = entryAfter ["theme"] pluginConfigs; extraPluginConfigs = entryAfter ["pluginConfigs"] extraPluginConfigs; mappings = entryAfter ["extraPluginConfigs"] keymaps; - # FIXME: put this somewhere less stupid - footer = entryAfter ["mappings"] (optionalString config.vim.lazy.enable "require('lzn-auto-require.loader').register_loader()"); }; builtLuaConfigRC = let