nix-community.nixvim/plugins/utils/nvim-autopairs.nix

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

209 lines
5.3 KiB
Nix
Raw Normal View History

{
lib,
helpers,
config,
pkgs,
...
}:
with lib;
helpers.neovim-plugin.mkNeovimPlugin config {
name = "nvim-autopairs";
defaultPackage = pkgs.vimPlugins.nvim-autopairs;
2024-05-05 19:39:35 +02:00
maintainers = [ maintainers.GaetanLepage ];
2024-05-05 19:39:35 +02:00
# TODO: introduced 2024-03-27, remove on 2024-05-27
deprecateExtraOptions = true;
optionsRenamedToSettings = [
"disableInMacro"
"disableInVisualblock"
"disableInReplaceMode"
"ignoredNextChar"
"enableMoveright"
"enableCheckBracketLine"
"enableBracketInQuote"
"enableAbbr"
"breakUndo"
"checkTs"
"tsConfig"
"mapCr"
"mapBs"
"mapCH"
"mapCW"
];
imports =
let
basePluginPaths = [
"plugins"
"nvim-autopairs"
];
settingsPath = basePluginPaths ++ [ "settings" ];
in
[
(mkRenamedOptionModule (basePluginPaths ++ [ "disabledFiletypes" ]) (
settingsPath ++ [ "disable_filetype" ]
))
(mkRenamedOptionModule (basePluginPaths ++ [ "enableAfterQuote" ]) (
settingsPath ++ [ "enable_afterquote" ]
))
(mkRemovedOptionModule (basePluginPaths ++ [ "pairs" ]) ''
This option was having no effect.
If you want to customize pairs, please use `extraConfigLua` to define them as described in the plugin documentation.
'')
];
settingsOptions = {
disable_filetype = helpers.defaultNullOpts.mkListOf types.str [
"TelescopePrompt"
"spectre_panel"
] "Disabled filetypes.";
disable_in_macro = helpers.defaultNullOpts.mkBool false ''
Disable when recording or executing a macro.
'';
2024-05-05 19:39:35 +02:00
disable_in_visualblock = helpers.defaultNullOpts.mkBool false ''
Disable when insert after visual block mode.
2024-05-05 19:39:35 +02:00
'';
disable_in_replace_mode = helpers.defaultNullOpts.mkBool true ''
Disable in replace mode.
2024-05-05 19:39:35 +02:00
'';
ignored_next_char = helpers.defaultNullOpts.mkLua "[=[[%w%%%'%[%\"%.%`%$]]=]" ''
Regexp to ignore if it matches the next character.
2024-05-05 19:39:35 +02:00
'';
enable_moveright = helpers.defaultNullOpts.mkBool true ''
Enable moveright.
2024-05-05 19:39:35 +02:00
'';
enable_afterquote = helpers.defaultNullOpts.mkBool true ''
Add bracket pairs after quote.
2024-05-05 19:39:35 +02:00
'';
enable_check_bracket_line = helpers.defaultNullOpts.mkBool true ''
Check bracket in same line.
2024-05-05 19:39:35 +02:00
'';
enable_bracket_in_quote = helpers.defaultNullOpts.mkBool true ''
Enable bracket in quote.
2024-05-05 19:39:35 +02:00
'';
enable_abbr = helpers.defaultNullOpts.mkBool false ''
Trigger abbreviation.
2024-05-05 19:39:35 +02:00
'';
break_undo = helpers.defaultNullOpts.mkBool true ''
Switch for basic rule break undo sequence.
2024-05-05 19:39:35 +02:00
'';
check_ts = helpers.defaultNullOpts.mkBool false ''
Use treesitter to check for a pair.
2024-05-05 19:39:35 +02:00
'';
ts_config = helpers.defaultNullOpts.mkAttrsOf types.anything {
lua = [
"string"
"source"
"string_content"
];
javascript = [
"string"
"template_string"
];
} "Configuration for TreeSitter.";
2024-05-05 19:39:35 +02:00
map_cr = helpers.defaultNullOpts.mkBool true ''
Map the `<CR>` key to confirm the completion.
2024-05-05 19:39:35 +02:00
'';
map_bs = helpers.defaultNullOpts.mkBool true ''
Map the `<BS>` key to delete the pair.
2024-05-05 19:39:35 +02:00
'';
map_c_h = helpers.defaultNullOpts.mkBool false ''
Map the `<C-h>` key to delete a pair.
2024-05-05 19:39:35 +02:00
'';
map_c_w = helpers.defaultNullOpts.mkBool false ''
Map the `<C-w>` key to delete a pair if possible.
2024-05-05 19:39:35 +02:00
'';
fast_wrap = {
map = helpers.defaultNullOpts.mkStr "<M-e>" ''
The key to trigger fast_wrap.
'';
chars =
helpers.defaultNullOpts.mkListOf types.str
[
"{"
"["
"("
"\""
"'"
]
''
Characters for which to enable fast wrap.
'';
pattern = helpers.defaultNullOpts.mkLua ''[=[[%'%"%>%]%)%}%,%`]]=]'' ''
The pattern to match against.
'';
end_key = helpers.defaultNullOpts.mkStr "$" ''
End key.
'';
before_key = helpers.defaultNullOpts.mkStr "h" ''
Before key.
'';
after_key = helpers.defaultNullOpts.mkStr "l" ''
After key.
'';
cursor_pos_before = helpers.defaultNullOpts.mkBool true ''
Whether the cursor should be placed before or after the substitution.
'';
keys = helpers.defaultNullOpts.mkStr "qwertyuiopzxcvbnmasdfghjkl" '''';
highlight = helpers.defaultNullOpts.mkStr "Search" ''
Which highlight group to use for the match.
'';
highlight_grey = helpers.defaultNullOpts.mkStr "Comment" ''
Which highlight group to use for the grey part.
'';
manual_position = helpers.defaultNullOpts.mkBool true ''
Whether to enable manual position.
'';
use_virt_lines = helpers.defaultNullOpts.mkBool true ''
Whether to use `virt_lines`.
'';
};
2024-05-05 19:39:35 +02:00
};
settingsExample = {
disable_filetype = [ "TelescopePrompt" ];
fast_wrap = {
map = "<M-e>";
end_key = "$";
};
2024-05-05 19:39:35 +02:00
};
extraConfig = cfg: {
warnings =
optional
((isBool cfg.settings.check_ts) && cfg.settings.check_ts && !config.plugins.treesitter.enable)
''
Nixvim (plugins.nvim-autopairs): You have set `settings.check_ts` to `true` but have not enabled the treesitter plugin.
We suggest you to set `plugins.treesitter.enable` to `true`.
'';
};
}