{lib, ...}: let inherit (lib.options) mkEnableOption mkOption literalMD; inherit (lib.types) listOf str either attrsOf submodule enum anything; inherit (lib.nvim.types) mkPluginSetupOption luaInline; inherit (lib.nvim.binds) mkMappingOption; keymapType = submodule { freeformType = attrsOf (listOf (either str luaInline)); options = { preset = mkOption { type = enum ["default" "none" "super-tab" "enter"]; default = "none"; description = "keymap presets"; }; }; }; providerType = submodule { freeformType = anything; options = { module = mkOption { type = str; description = "module of the provider"; }; }; }; in { options.vim.autocomplete.blink-cmp = { enable = mkEnableOption "blink.cmp"; setupOpts = mkPluginSetupOption "blink.cmp" { sources = { default = mkOption { type = listOf str; description = "Default list of sources to enable for completion."; default = ["lsp" "path" "snippets" "buffer"]; }; providers = mkOption { type = attrsOf providerType; description = "Providers"; default = {}; }; }; keymap = mkOption { type = keymapType; default = {}; description = "blink.cmp keymap"; example = literalMD '' ```nix vim.autocomplete.blink-cmp.setupOpts.keymap = { preset = "none"; "" = ["select_prev" "fallback"]; "" = [ (lib.generators.mkLuaInline '''' function(cmp) if some_condition then return end -- runs the next command return true -- doesn't run the next command end, '''') "select_next" ]; }; ``` ''; }; }; mappings = { complete = mkMappingOption "Complete [blink.cmp]" ""; confirm = mkMappingOption "Confirm [blink.cmp]" ""; next = mkMappingOption "Next item [blink.cmp]" ""; previous = mkMappingOption "Previous item [blink.cmp]" ""; close = mkMappingOption "Close [blink.cmp]" ""; scrollDocsUp = mkMappingOption "Scroll docs up [blink.cmp]" ""; scrollDocsDown = mkMappingOption "Scroll docs down [blink.cmp]" ""; }; }; }