mirror of
https://github.com/NotAShelf/neovim-flake.git
synced 2024-11-09 14:45:58 +01:00
plugins/treesitter: move nvim-treesitter-context to its own dir
This commit is contained in:
parent
2680be20a3
commit
495e7620d2
3 changed files with 97 additions and 0 deletions
31
modules/plugins/treesitter/ts-context/config.nix
Normal file
31
modules/plugins/treesitter/ts-context/config.nix
Normal file
|
@ -0,0 +1,31 @@
|
||||||
|
{
|
||||||
|
config,
|
||||||
|
lib,
|
||||||
|
...
|
||||||
|
}: let
|
||||||
|
inherit (lib.modules) mkIf;
|
||||||
|
inherit (lib.trivial) boolToString;
|
||||||
|
inherit (lib.nvim.lua) nullString;
|
||||||
|
inherit (lib.nvim.dag) entryAfter;
|
||||||
|
|
||||||
|
inherit (config.vim) treesitter;
|
||||||
|
cfg = treesitter.context;
|
||||||
|
in {
|
||||||
|
config = mkIf (treesitter.enable && cfg.enable) {
|
||||||
|
vim.startPlugins = ["nvim-treesitter-context"];
|
||||||
|
|
||||||
|
vim.luaConfigRC.treesitter-context = entryAfter ["treesitter"] ''
|
||||||
|
require'treesitter-context'.setup {
|
||||||
|
enable = true,
|
||||||
|
max_lines = ${toString cfg.maxLines},
|
||||||
|
min_window_height = ${toString cfg.minWindowHeight},
|
||||||
|
line_numbers = ${boolToString cfg.lineNumbers},
|
||||||
|
multiline_threshold = ${toString cfg.multilineThreshold},
|
||||||
|
trim_scope = '${cfg.trimScope}',
|
||||||
|
mode = '${cfg.mode}',
|
||||||
|
separator = ${nullString cfg.separator},
|
||||||
|
max_lines = ${toString cfg.zindex},
|
||||||
|
}
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
}
|
60
modules/plugins/treesitter/ts-context/context.nix
Normal file
60
modules/plugins/treesitter/ts-context/context.nix
Normal file
|
@ -0,0 +1,60 @@
|
||||||
|
{lib, ...}: let
|
||||||
|
inherit (lib.options) mkOption mkEnableOption;
|
||||||
|
inherit (lib.types) int bool str nullOr enum;
|
||||||
|
in {
|
||||||
|
options.vim.treesitter.context = {
|
||||||
|
enable = mkEnableOption "context of current buffer contents [nvim-treesitter-context] ";
|
||||||
|
|
||||||
|
maxLines = mkOption {
|
||||||
|
type = int;
|
||||||
|
default = 0;
|
||||||
|
description = "How many lines the window should span. Values <=0 mean no limit.";
|
||||||
|
};
|
||||||
|
|
||||||
|
minWindowHeight = mkOption {
|
||||||
|
type = int;
|
||||||
|
default = 0;
|
||||||
|
description = "Minimum editor window height to enable context. Values <= 0 mean no limit.";
|
||||||
|
};
|
||||||
|
|
||||||
|
lineNumbers = mkOption {
|
||||||
|
type = bool;
|
||||||
|
default = true;
|
||||||
|
description = "";
|
||||||
|
};
|
||||||
|
|
||||||
|
multilineThreshold = mkOption {
|
||||||
|
type = int;
|
||||||
|
default = 20;
|
||||||
|
description = "Maximum number of lines to collapse for a single context line.";
|
||||||
|
};
|
||||||
|
|
||||||
|
trimScope = mkOption {
|
||||||
|
type = enum ["inner" "outer"];
|
||||||
|
default = "outer";
|
||||||
|
description = "Which context lines to discard if [](#opt-vim.treesitter.context.maxLines) is exceeded.";
|
||||||
|
};
|
||||||
|
|
||||||
|
mode = mkOption {
|
||||||
|
type = enum ["cursor" "topline"];
|
||||||
|
default = "cursor";
|
||||||
|
description = "Line used to calculate context.";
|
||||||
|
};
|
||||||
|
|
||||||
|
separator = mkOption {
|
||||||
|
type = nullOr str;
|
||||||
|
default = null;
|
||||||
|
description = ''
|
||||||
|
Separator between context and content. 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.
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
|
||||||
|
zindex = mkOption {
|
||||||
|
type = int;
|
||||||
|
default = 20;
|
||||||
|
description = "The Z-index of the context window.";
|
||||||
|
};
|
||||||
|
};
|
||||||
|
}
|
6
modules/plugins/treesitter/ts-context/default.nix
Normal file
6
modules/plugins/treesitter/ts-context/default.nix
Normal file
|
@ -0,0 +1,6 @@
|
||||||
|
{
|
||||||
|
imports = [
|
||||||
|
./context.nix
|
||||||
|
./config.nix
|
||||||
|
];
|
||||||
|
}
|
Loading…
Reference in a new issue