This commit is contained in:
Pedro Alves 2023-02-20 10:43:13 +00:00
parent 8798a622cf
commit 3e73b2900c

View file

@ -1,12 +1,12 @@
{ pkgs {
, config pkgs,
, lib config,
, ... lib,
...
} @ args: } @ args:
with lib; let with lib; let
helpers = import ../helpers.nix args; helpers = import ../helpers.nix args;
in in {
{
options.plugins.vim-matchup = { options.plugins.vim-matchup = {
enable = mkEnableOption "Enable vim-matchup"; enable = mkEnableOption "Enable vim-matchup";
@ -16,7 +16,7 @@ in
enable = mkEnableOption "Enable treesitter integration"; enable = mkEnableOption "Enable treesitter integration";
disable = disable =
helpers.defaultNullOpts.mkNullable (types.listOf types.str) "[]" helpers.defaultNullOpts.mkNullable (types.listOf types.str) "[]"
"Languages for each to disable this module"; "Languages for each to disable this module";
disableVirtualText = helpers.defaultNullOpts.mkBool false '' disableVirtualText = helpers.defaultNullOpts.mkBool false ''
Do not use virtual text to highlight the virtual end of a block, for languages without Do not use virtual text to highlight the virtual end of a block, for languages without
@ -37,34 +37,34 @@ in
singleton = singleton =
helpers.defaultNullOpts.mkBool false helpers.defaultNullOpts.mkBool false
"Whether to highlight known words even if there is no match"; "Whether to highlight known words even if there is no match";
offscreen = offscreen =
helpers.defaultNullOpts.mkNullable helpers.defaultNullOpts.mkNullable
(types.submodule { (types.submodule {
options = { options = {
method = helpers.defaultNullOpts.mkEnumFirstDefault [ "status" "popup" "status_manual" ] '' method = helpers.defaultNullOpts.mkEnumFirstDefault ["status" "popup" "status_manual"] ''
'status': Replace the status-line for off-screen matches. 'status': Replace the status-line for off-screen matches.
If a match is off of the screen, the line belonging to that match will be displayed If a match is off of the screen, the line belonging to that match will be displayed
syntax-highlighted in the status line along with the line number (if line numbers syntax-highlighted in the status line along with the line number (if line numbers
are enabled). If the match is above the screen border, an additional Δ symbol will are enabled). If the match is above the screen border, an additional Δ symbol will
be shown to indicate that the matching line is really above the cursor line. be shown to indicate that the matching line is really above the cursor line.
'popup': Show off-screen matches in a popup (vim) or floating (neovim) window. 'popup': Show off-screen matches in a popup (vim) or floating (neovim) window.
'status_manual': Compute the string which would be displayed in the status-line or 'status_manual': Compute the string which would be displayed in the status-line or
popup, but do not display it. The function MatchupStatusOffscreen() can be used to popup, but do not display it. The function MatchupStatusOffscreen() can be used to
get the text. get the text.
''; '';
scrolloff = helpers.defaultNullOpts.mkBool false '' scrolloff = helpers.defaultNullOpts.mkBool false ''
When enabled, off-screen matches will not be shown in the statusline while the When enabled, off-screen matches will not be shown in the statusline while the
cursor is at the screen edge (respects the value of 'scrolloff'). cursor is at the screen edge (respects the value of 'scrolloff').
This is intended to prevent flickering while scrolling with j and k. This is intended to prevent flickering while scrolling with j and k.
''; '';
}; };
}) })
''{method = "status";}'' "Dictionary controlling the behavior with off-screen matches."; ''{method = "status";}'' "Dictionary controlling the behavior with off-screen matches.";
stopline = helpers.defaultNullOpts.mkInt 400 '' stopline = helpers.defaultNullOpts.mkInt 400 ''
The number of lines to search in either direction while highlighting matches. The number of lines to search in either direction while highlighting matches.
@ -73,11 +73,11 @@ in
timeout = timeout =
helpers.defaultNullOpts.mkInt 300 helpers.defaultNullOpts.mkInt 300
"Adjust timeouts in milliseconds for matchparen highlighting"; "Adjust timeouts in milliseconds for matchparen highlighting";
insertTimeout = insertTimeout =
helpers.defaultNullOpts.mkInt 60 helpers.defaultNullOpts.mkInt 60
"Adjust timeouts in milliseconds for matchparen highlighting"; "Adjust timeouts in milliseconds for matchparen highlighting";
deffered = { deffered = {
enable = helpers.defaultNullOpts.mkBool false '' enable = helpers.defaultNullOpts.mkBool false ''
@ -123,12 +123,12 @@ in
linewiseOperators = linewiseOperators =
helpers.defaultNullOpts.mkNullable (types.listOf types.str) helpers.defaultNullOpts.mkNullable (types.listOf types.str)
''["d" "y"]'' "Modify the set of operators which may operate line-wise"; ''["d" "y"]'' "Modify the set of operators which may operate line-wise";
}; };
enableSurround = enableSurround =
helpers.defaultNullOpts.mkBool false helpers.defaultNullOpts.mkBool false
"To enable the delete surrounding (ds%) and change surrounding (cs%) maps"; "To enable the delete surrounding (ds%) and change surrounding (cs%) maps";
enableTransmute = enableTransmute =
helpers.defaultNullOpts.mkBool false "To enable the experimental transmute module"; helpers.defaultNullOpts.mkBool false "To enable the experimental transmute module";
@ -138,7 +138,7 @@ in
objects. Does not apply to match highlighting (see matchParenStopline instead) objects. Does not apply to match highlighting (see matchParenStopline instead)
''; '';
delimNoSkips = helpers.defaultNullOpts.mkNullable (types.enum [ 0 1 2 ]) "0" '' delimNoSkips = helpers.defaultNullOpts.mkNullable (types.enum [0 1 2]) "0" ''
To disable matching within strings and comments: To disable matching within strings and comments:
- 0: matching is enabled within strings and comments - 0: matching is enabled within strings and comments
- 1: recognize symbols within comments - 1: recognize symbols within comments
@ -146,12 +146,11 @@ in
''; '';
}; };
config = config = let
let cfg = config.plugins.vim-matchup;
cfg = config.plugins.vim-matchup; in
in
mkIf cfg.enable { mkIf cfg.enable {
extraPlugins = [ cfg.package ]; extraPlugins = [cfg.package];
plugins.treesitter.moduleConfig.matchup = mkIf cfg.treesitterIntegration.enable { plugins.treesitter.moduleConfig.matchup = mkIf cfg.treesitterIntegration.enable {
inherit (cfg.treesitterIntegration) enable disable; inherit (cfg.treesitterIntegration) enable disable;