2023-01-19 10:45:15 +00:00
|
|
|
{ pkgs
|
|
|
|
, lib
|
|
|
|
, config
|
|
|
|
, ...
|
2023-01-06 12:31:54 +01:00
|
|
|
}:
|
2023-01-25 19:46:49 +01:00
|
|
|
with lib;
|
|
|
|
let
|
|
|
|
helpers = import ../helpers.nix { inherit lib; };
|
|
|
|
in {
|
2023-01-06 12:31:54 +01:00
|
|
|
options.plugins.treesitter-context = {
|
2023-01-22 03:32:08 +00:00
|
|
|
enable = mkEnableOption "nvim-treesitter-context";
|
2023-01-06 12:31:54 +01:00
|
|
|
|
2023-01-25 19:46:49 +01:00
|
|
|
package = helpers.mkPackageOption "treesitter-context" pkgs.vimPlugins.nvim-treesitter-context;
|
2023-01-19 10:45:15 +00:00
|
|
|
|
2023-01-06 12:31:54 +01:00
|
|
|
maxLines = mkOption {
|
|
|
|
type = types.nullOr types.ints.positive;
|
|
|
|
default = null;
|
|
|
|
description = "How many lines the window should span. Null means no limit";
|
|
|
|
};
|
|
|
|
|
|
|
|
trimScope = mkOption {
|
2023-01-19 10:45:15 +00:00
|
|
|
type = types.enum [ "outer" "inner" ];
|
2023-01-06 12:31:54 +01:00
|
|
|
default = "outer";
|
|
|
|
description = "Which context lines to discard if `max_lines` is exceeded";
|
|
|
|
};
|
|
|
|
|
|
|
|
maxWindowHeight = mkOption {
|
|
|
|
type = types.nullOr types.ints.positive;
|
|
|
|
default = null;
|
|
|
|
description = "Minimum editor window height to enable context";
|
|
|
|
};
|
|
|
|
|
|
|
|
patterns = mkOption {
|
|
|
|
type = types.attrsOf (types.listOf types.str);
|
2023-01-19 10:45:15 +00:00
|
|
|
default = { };
|
2023-01-06 12:31:54 +01:00
|
|
|
description = ''
|
|
|
|
Patterns to use for context delimitation. The 'default' key matches all filetypes
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
|
|
|
exactPatterns = mkOption {
|
|
|
|
type = types.attrsOf types.bool;
|
2023-01-19 10:45:15 +00:00
|
|
|
default = { };
|
2023-01-06 12:31:54 +01:00
|
|
|
description = "Treat the coresponding entry in patterns as an exact match";
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
2023-01-19 10:45:15 +00:00
|
|
|
config =
|
|
|
|
let
|
|
|
|
cfg = config.plugins.treesitter-context;
|
|
|
|
in
|
2023-01-06 12:31:54 +01:00
|
|
|
mkIf cfg.enable {
|
2023-01-19 10:45:15 +00:00
|
|
|
extraPlugins = [ cfg.package ];
|
2023-01-06 12:31:54 +01:00
|
|
|
|
|
|
|
plugins.treesitter.moduleConfig.context = {
|
|
|
|
max_lines = cfg.maxLines;
|
|
|
|
trim_scope = cfg.trimScope;
|
|
|
|
min_window_height = cfg.maxWindowHeight;
|
|
|
|
};
|
|
|
|
};
|
|
|
|
}
|