plugins/indent-blankline: swith to mkNeovimPlugin

This commit is contained in:
Gaetan Lepage 2024-03-10 00:44:02 +01:00 committed by Gaétan Lepage
parent 83ca67566d
commit 2799e830b2
2 changed files with 157 additions and 136 deletions

View file

@ -5,19 +5,49 @@
pkgs, pkgs,
... ...
}: }:
with lib; { with lib;
options.plugins.indent-blankline = helpers.neovim-plugin.mkNeovimPlugin config {
helpers.neovim-plugin.extraOptionsOptions name = "indent-blankline";
// { originalName = "indent-blankline.nvim";
enable = mkEnableOption "indent-blankline.nvim"; luaName = "ibl";
defaultPackage = pkgs.vimPlugins.indent-blankline-nvim;
package = helpers.mkPackageOption "indent-blankline" pkgs.vimPlugins.indent-blankline-nvim; maintainers = [maintainers.GaetanLepage];
# TODO introduced 2024-03-10: remove 2024-05-10
deprecateExtraOptions = true;
optionsRenamedToSettings = [
"debounce"
["viewportBuffer" "min"]
["viewportBuffer" "max"]
["indent" "char"]
["indent" "tabChar"]
["indent" "highlight"]
["indent" "smartIndentCap"]
["indent" "priority"]
["whitespace" "highlight"]
["whitespace" "removeBlanklineTrail"]
["scope" "enabled"]
["scope" "char"]
["scope" "showStart"]
["scope" "showEnd"]
["scope" "showExactScope"]
["scope" "injectedLanguages"]
["scope" "highlight"]
["scope" "priority"]
["scope" "include" "nodeType"]
["scope" "exclude" "language"]
["scope" "exclude" "nodeType"]
["exclude" "filetypes"]
["exclude" "buftypes"]
];
settingsOptions = {
debounce = helpers.defaultNullOpts.mkUnsignedInt 200 '' debounce = helpers.defaultNullOpts.mkUnsignedInt 200 ''
Sets the amount indent-blankline debounces refreshes in milliseconds. Sets the amount indent-blankline debounces refreshes in milliseconds.
''; '';
viewportBuffer = { viewport_buffer = {
min = helpers.defaultNullOpts.mkUnsignedInt 30 '' min = helpers.defaultNullOpts.mkUnsignedInt 30 ''
Minimum number of lines above and below of what is currently visible in the window for Minimum number of lines above and below of what is currently visible in the window for
which indentation guides will be generated. which indentation guides will be generated.
@ -35,7 +65,7 @@ with lib; {
Each character has to have a display width of 0 or 1. Each character has to have a display width of 0 or 1.
''; '';
tabChar = helpers.mkNullOrOption (with types; either str (listOf str)) '' tab_char = helpers.mkNullOrOption (with types; either str (listOf str)) ''
Character, or list of characters, that get used to display the indentation guide for tabs. Character, or list of characters, that get used to display the indentation guide for tabs.
Each character has to have a display width of 0 or 1. Each character has to have a display width of 0 or 1.
@ -49,7 +79,7 @@ with lib; {
Default: `|hl-IblIndent|` Default: `|hl-IblIndent|`
''; '';
smartIndentCap = helpers.defaultNullOpts.mkBool true '' smart_indent_cap = helpers.defaultNullOpts.mkBool true ''
Caps the number of indentation levels by looking at the surrounding code. Caps the number of indentation levels by looking at the surrounding code.
''; '';
@ -65,7 +95,7 @@ with lib; {
Default: `|hl-IblWhitespace|` Default: `|hl-IblWhitespace|`
''; '';
removeBlanklineTrail = helpers.defaultNullOpts.mkBool true '' remove_blankline_trail = helpers.defaultNullOpts.mkBool true ''
Removes trailing whitespace on blanklines. Removes trailing whitespace on blanklines.
Turn this off if you want to add background color to the whitespace highlight group. Turn this off if you want to add background color to the whitespace highlight group.
@ -83,21 +113,21 @@ with lib; {
Default: `indent.char` Default: `indent.char`
''; '';
showStart = helpers.defaultNullOpts.mkBool true '' show_start = helpers.defaultNullOpts.mkBool true ''
Shows an underline on the first line of the scope. Shows an underline on the first line of the scope.
''; '';
showEnd = helpers.defaultNullOpts.mkBool true '' show_end = helpers.defaultNullOpts.mkBool true ''
Shows an underline on the last line of the scope. Shows an underline on the last line of the scope.
''; '';
showExactScope = helpers.defaultNullOpts.mkBool false '' show_exact_scope = helpers.defaultNullOpts.mkBool false ''
Shows an underline on the first line of the scope starting at the exact start of the scope Shows an underline on the first line of the scope starting at the exact start of the scope
(even if this is to the right of the indent guide) and an underline on the last line of (even if this is to the right of the indent guide) and an underline on the last line of
the scope ending at the exact end of the scope. the scope ending at the exact end of the scope.
''; '';
injectedLanguages = helpers.defaultNullOpts.mkBool true '' injected_languages = helpers.defaultNullOpts.mkBool true ''
Checks for the current scope in injected treesitter languages. Checks for the current scope in injected treesitter languages.
This also influences if the scope gets excluded or not. This also influences if the scope gets excluded or not.
''; '';
@ -113,7 +143,7 @@ with lib; {
''; '';
include = { include = {
nodeType = helpers.defaultNullOpts.mkNullable (with types; attrsOf (listOf str)) "{}" '' node_type = helpers.defaultNullOpts.mkAttrsOf (with types; listOf str) "{}" ''
Map of language to a list of node types which can be used as scope. Map of language to a list of node types which can be used as scope.
- Use `*` as the language to act as a wildcard for all languages. - Use `*` as the language to act as a wildcard for all languages.
@ -122,13 +152,12 @@ with lib; {
}; };
exclude = { exclude = {
language = helpers.defaultNullOpts.mkNullable (with types; listOf str) "[]" '' language = helpers.defaultNullOpts.mkListOf types.str "[]" ''
List of treesitter languages for which scope is disabled. List of treesitter languages for which scope is disabled.
''; '';
nodeType = node_type =
helpers.defaultNullOpts.mkNullable helpers.defaultNullOpts.mkAttrsOf (with types; (listOf str))
(with types; attrsOf (listOf str))
'' ''
{ {
"*" = ["source_file" "program"]; "*" = ["source_file" "program"];
@ -146,8 +175,7 @@ with lib; {
exclude = { exclude = {
filetypes = filetypes =
helpers.defaultNullOpts.mkNullable helpers.defaultNullOpts.mkListOf types.str
(with types; listOf str)
'' ''
[ [
"lspinfo" "lspinfo"
@ -164,8 +192,7 @@ with lib; {
"List of filetypes for which indent-blankline is disabled."; "List of filetypes for which indent-blankline is disabled.";
buftypes = buftypes =
helpers.defaultNullOpts.mkNullable helpers.defaultNullOpts.mkListOf types.str
(with types; listOf str)
'' ''
[ [
"terminal" "terminal"
@ -178,65 +205,27 @@ with lib; {
}; };
}; };
config = let settingsExample = {
cfg = config.plugins.indent-blankline; indent = {
in char = "";
mkIf cfg.enable {
extraPlugins = [cfg.package];
extraConfigLua = let
setupOptions = with cfg;
{
enabled = true;
inherit debounce;
viewport_buffer = with viewportBuffer; {
inherit
min
max
;
}; };
indent = with indent; { scope = {
inherit char; show_start = false;
tab_char = tabChar; show_end = false;
inherit highlight; show_exact_scope = true;
smart_indent_cap = smartIndentCap;
inherit priority;
}; };
whitespace = with whitespace; { exclude = {
inherit highlight; filetypes = [
remove_blankline_trail = removeBlanklineTrail; ""
"checkhealth"
"help"
"lspinfo"
"packer"
"TelescopePrompt"
"TelescopeResults"
"yaml"
];
buftypes = ["terminal" "quickfix"];
}; };
scope = with scope; {
inherit
enabled
char
;
show_start = showStart;
show_end = showEnd;
show_exact_scope = showExactScope;
injected_languages = injectedLanguages;
inherit
highlight
priority
;
include = with include; {
node_type = nodeType;
};
exclude = with exclude; {
inherit language;
node_type = nodeType;
};
};
exclude = with exclude; {
inherit
filetypes
buftypes
;
};
}
// cfg.extraOptions;
in ''
require("ibl").setup(${helpers.toLuaObject setupOptions})
'';
}; };
} }

View file

@ -3,41 +3,72 @@
plugins.indent-blankline.enable = true; plugins.indent-blankline.enable = true;
}; };
example = {
plugins.indent-blankline = {
enable = true;
settings = {
indent = {
char = "";
};
scope = {
show_start = false;
show_end = false;
show_exact_scope = true;
};
exclude = {
filetypes = [
""
"checkhealth"
"help"
"lspinfo"
"packer"
"TelescopePrompt"
"TelescopeResults"
"yaml"
];
buftypes = ["terminal" "quickfix"];
};
};
};
};
defaults = { defaults = {
plugins.indent-blankline = { plugins.indent-blankline = {
enable = true; enable = true;
settings = {
debounce = 200; debounce = 200;
viewportBuffer = { viewport_buffer = {
min = 30; min = 30;
max = 500; max = 500;
}; };
indent = { indent = {
char = ""; char = "";
tabChar = null; tab_char = null;
highlight = null; highlight = null;
smartIndentCap = true; smart_indent_cap = true;
priority = 1; priority = 1;
}; };
whitespace = { whitespace = {
highlight = null; highlight = null;
removeBlanklineTrail = true; remove_blankline_trail = true;
}; };
scope = { scope = {
enabled = true; enabled = true;
char = null; char = null;
showStart = true; show_start = true;
showEnd = true; show_end = true;
showExactScope = false; show_exact_scope = false;
injectedLanguages = true; injected_languages = true;
highlight = null; highlight = null;
priority = 1024; priority = 1024;
include = { include = {
nodeType = {}; node_type = {};
}; };
exclude = { exclude = {
language = []; language = [];
nodeType = { node_type = {
"*" = ["source_file" "program"]; "*" = ["source_file" "program"];
lua = ["chunk"]; lua = ["chunk"];
python = ["module"]; python = ["module"];
@ -65,4 +96,5 @@
}; };
}; };
}; };
};
} }