2024-04-23 13:08:36 +00:00
|
|
|
{lib, ...}: let
|
|
|
|
inherit (lib.options) mkOption mkEnableOption;
|
|
|
|
inherit (lib.types) int bool str nullOr enum;
|
2024-04-28 17:19:25 +00:00
|
|
|
inherit (lib.nvim.types) mkPluginSetupOption;
|
|
|
|
inherit (lib.nvim.config) batchRenameOptions;
|
|
|
|
migrationTable = {
|
|
|
|
maxLines = "max_lines";
|
|
|
|
minWindowHeight = "min_window_height";
|
|
|
|
lineNumbers = "line_numbers";
|
|
|
|
multilineThreshold = "multiline_threshold";
|
|
|
|
trimScope = "trim_scope";
|
|
|
|
mode = "mode";
|
2024-11-26 07:36:39 +00:00
|
|
|
separator = "separator";
|
2024-04-28 17:19:25 +00:00
|
|
|
zindex = "z_index";
|
|
|
|
};
|
|
|
|
|
|
|
|
renamedSetupOpts =
|
|
|
|
batchRenameOptions
|
|
|
|
["vim" "treesitter" "context"]
|
|
|
|
["vim" "treesitter" "context" "setupOpts"]
|
|
|
|
migrationTable;
|
2024-04-23 13:08:36 +00:00
|
|
|
in {
|
2024-04-28 17:19:25 +00:00
|
|
|
imports = renamedSetupOpts;
|
2024-04-23 13:08:36 +00:00
|
|
|
options.vim.treesitter.context = {
|
|
|
|
enable = mkEnableOption "context of current buffer contents [nvim-treesitter-context] ";
|
|
|
|
|
2024-04-28 17:19:25 +00:00
|
|
|
setupOpts = mkPluginSetupOption "treesitter-context" {
|
|
|
|
max_lines = mkOption {
|
|
|
|
type = int;
|
|
|
|
default = 0;
|
|
|
|
description = ''
|
|
|
|
How many lines the window should span.
|
2024-04-23 13:08:36 +00:00
|
|
|
|
2024-04-28 17:19:25 +00:00
|
|
|
Values >= 0 mean there will be no limit.
|
|
|
|
'';
|
|
|
|
};
|
2024-04-23 13:08:36 +00:00
|
|
|
|
2024-04-28 17:19:25 +00:00
|
|
|
min_window_height = mkOption {
|
|
|
|
type = int;
|
|
|
|
default = 0;
|
|
|
|
description = ''
|
|
|
|
Minimum editor window height to enable context.
|
2024-04-23 13:08:36 +00:00
|
|
|
|
2024-04-28 17:19:25 +00:00
|
|
|
Values >= 0 mean there will be no limit.
|
|
|
|
'';
|
|
|
|
};
|
2024-04-23 13:08:36 +00:00
|
|
|
|
2024-04-28 17:19:25 +00:00
|
|
|
line_numbers = mkOption {
|
|
|
|
type = bool;
|
|
|
|
default = true;
|
|
|
|
description = "Whether to display line numbers in current context";
|
|
|
|
};
|
2024-04-23 13:08:36 +00:00
|
|
|
|
2024-04-28 17:19:25 +00:00
|
|
|
multiline_threshold = mkOption {
|
|
|
|
type = int;
|
|
|
|
default = 20;
|
|
|
|
description = "Maximum number of lines to collapse for a single context line.";
|
|
|
|
};
|
2024-04-23 13:08:36 +00:00
|
|
|
|
2024-04-28 17:19:25 +00:00
|
|
|
trim_scope = mkOption {
|
|
|
|
type = enum ["inner" "outer"];
|
|
|
|
default = "outer";
|
|
|
|
description = ''
|
|
|
|
Which context lines to discard if
|
|
|
|
[](#opt-vim.treesitter.context.setupOpts.max_lines) is exceeded.
|
|
|
|
'';
|
|
|
|
};
|
2024-04-23 13:08:36 +00:00
|
|
|
|
2024-04-28 17:19:25 +00:00
|
|
|
mode = mkOption {
|
|
|
|
type = enum ["cursor" "topline"];
|
|
|
|
default = "cursor";
|
|
|
|
description = "Line used to calculate context.";
|
|
|
|
};
|
|
|
|
|
|
|
|
separator = mkOption {
|
|
|
|
type = nullOr str;
|
|
|
|
default = "-";
|
|
|
|
description = ''
|
|
|
|
Separator between context and content. This option should
|
|
|
|
be a single character string, like '-'.
|
|
|
|
|
|
|
|
When separator is set, the context will only show up when
|
|
|
|
there are at least 2 lines above cursorline.
|
|
|
|
'';
|
|
|
|
};
|
2024-04-23 13:08:36 +00:00
|
|
|
|
2024-04-28 17:19:25 +00:00
|
|
|
zindex = mkOption {
|
|
|
|
type = int;
|
|
|
|
default = 20;
|
|
|
|
description = "The Z-index of the context window.";
|
|
|
|
};
|
2024-04-23 13:08:36 +00:00
|
|
|
};
|
|
|
|
};
|
|
|
|
}
|