2021-03-17 22:33:03 +00:00
|
|
|
{ pkgs, config, lib, ... }:
|
|
|
|
with lib;
|
|
|
|
let
|
2022-09-18 11:19:23 +01:00
|
|
|
cfg = config.plugins.nvim-autopairs;
|
2023-01-25 19:46:49 +01:00
|
|
|
helpers = import ../helpers.nix { inherit lib; };
|
2021-03-17 22:33:03 +00:00
|
|
|
in
|
|
|
|
{
|
2022-09-18 11:19:23 +01:00
|
|
|
options.plugins.nvim-autopairs = {
|
2023-01-22 03:32:08 +00:00
|
|
|
enable = mkEnableOption "nvim-autopairs";
|
2021-03-17 22:33:03 +00:00
|
|
|
|
2023-01-25 19:46:49 +01:00
|
|
|
package = helpers.mkPackageOption "nvim-autopairs" pkgs.vimPlugins.nvim-autopairs;
|
2023-01-19 10:45:15 +00:00
|
|
|
|
2021-03-17 22:33:03 +00:00
|
|
|
pairs = mkOption {
|
|
|
|
type = types.nullOr (types.attrsOf types.str);
|
|
|
|
default = null;
|
|
|
|
description = "Characters to pair up";
|
|
|
|
};
|
|
|
|
|
|
|
|
disabledFiletypes = mkOption {
|
|
|
|
type = types.nullOr (types.listOf types.str);
|
|
|
|
default = null;
|
|
|
|
description = "Disabled filetypes";
|
|
|
|
};
|
|
|
|
|
|
|
|
breakLineFiletypes = mkOption {
|
|
|
|
type = types.nullOr (types.listOf types.str);
|
|
|
|
default = null;
|
|
|
|
description = "Filetypes to break lines on";
|
|
|
|
};
|
|
|
|
|
|
|
|
htmlFiletypes = mkOption {
|
|
|
|
type = types.nullOr (types.listOf types.str);
|
|
|
|
default = null;
|
|
|
|
description = "Filetypes to treat as HTML";
|
|
|
|
};
|
|
|
|
|
|
|
|
ignoredNextChar = mkOption {
|
|
|
|
type = types.nullOr types.str;
|
|
|
|
default = null;
|
|
|
|
description = "Regexp to ignore if it matches the next character";
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
2022-09-18 11:19:23 +01:00
|
|
|
config =
|
|
|
|
let
|
|
|
|
options = {
|
|
|
|
pairs_map = cfg.pairs;
|
|
|
|
disable_filetype = cfg.disabledFiletypes;
|
|
|
|
break_line_filetype = cfg.breakLineFiletypes;
|
|
|
|
html_break_line_filetype = cfg.htmlFiletypes;
|
|
|
|
ignored_next_char = cfg.ignoredNextChar;
|
|
|
|
};
|
|
|
|
in
|
|
|
|
mkIf cfg.enable {
|
2023-01-19 10:45:15 +00:00
|
|
|
extraPlugins = [ cfg.package ];
|
2021-03-17 22:33:03 +00:00
|
|
|
|
|
|
|
extraConfigLua = ''
|
|
|
|
require('nvim-autopairs').setup(${helpers.toLuaObject options})
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
}
|