mirror of
https://github.com/nix-community/nixvim.git
synced 2025-07-01 21:04:30 +02:00
treesitter: add tree-sitter context plugin (#103)
This commit is contained in:
parent
1f723e8abd
commit
2f9c21ffc8
2 changed files with 57 additions and 0 deletions
|
@ -24,6 +24,7 @@
|
||||||
./languages/ledger.nix
|
./languages/ledger.nix
|
||||||
./languages/nix.nix
|
./languages/nix.nix
|
||||||
./languages/treesitter.nix
|
./languages/treesitter.nix
|
||||||
|
./languages/treesitter-context.nix
|
||||||
./languages/treesitter-refactor.nix
|
./languages/treesitter-refactor.nix
|
||||||
./languages/zig.nix
|
./languages/zig.nix
|
||||||
|
|
||||||
|
|
56
plugins/languages/treesitter-context.nix
Normal file
56
plugins/languages/treesitter-context.nix
Normal file
|
@ -0,0 +1,56 @@
|
||||||
|
{
|
||||||
|
pkgs,
|
||||||
|
lib,
|
||||||
|
config,
|
||||||
|
...
|
||||||
|
}:
|
||||||
|
with lib; {
|
||||||
|
options.plugins.treesitter-context = {
|
||||||
|
enable = mkEnableOption "Enable nvim-treesitter-context";
|
||||||
|
|
||||||
|
maxLines = mkOption {
|
||||||
|
type = types.nullOr types.ints.positive;
|
||||||
|
default = null;
|
||||||
|
description = "How many lines the window should span. Null means no limit";
|
||||||
|
};
|
||||||
|
|
||||||
|
trimScope = mkOption {
|
||||||
|
type = types.enum ["outer" "inner"];
|
||||||
|
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);
|
||||||
|
default = {};
|
||||||
|
description = ''
|
||||||
|
Patterns to use for context delimitation. The 'default' key matches all filetypes
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
|
||||||
|
exactPatterns = mkOption {
|
||||||
|
type = types.attrsOf types.bool;
|
||||||
|
default = {};
|
||||||
|
description = "Treat the coresponding entry in patterns as an exact match";
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
config = let
|
||||||
|
cfg = config.plugins.treesitter-context;
|
||||||
|
in
|
||||||
|
mkIf cfg.enable {
|
||||||
|
extraPlugins = with pkgs.vimPlugins; [nvim-treesitter-context];
|
||||||
|
|
||||||
|
plugins.treesitter.moduleConfig.context = {
|
||||||
|
max_lines = cfg.maxLines;
|
||||||
|
trim_scope = cfg.trimScope;
|
||||||
|
min_window_height = cfg.maxWindowHeight;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
}
|
Loading…
Add table
Add a link
Reference in a new issue