|
6 | 6 | }:
|
7 | 7 | with lib;
|
8 | 8 | with builtins; let
|
9 |
| - cfg = config.vim.treesitter; |
| 9 | + treesitter = config.vim.treesitter; |
| 10 | + cfg = treesitter.context; |
10 | 11 | in {
|
11 |
| - options.vim.treesitter.context.enable = mkOption { |
12 |
| - type = types.bool; |
13 |
| - default = false; |
14 |
| - description = "enable function context [nvim-treesitter-context]"; |
| 12 | + options.vim.treesitter.context = { |
| 13 | + enable = mkEnableOption "context of current buffer contents [nvim-treesitter-context] "; |
| 14 | + |
| 15 | + maxLines = mkOption { |
| 16 | + description = "How many lines the window should span. Values <= 0 mean no limit."; |
| 17 | + type = types.int; |
| 18 | + default = 0; |
| 19 | + }; |
| 20 | + |
| 21 | + minWindowHeight = mkOption { |
| 22 | + description = "Minimum editor window height to enable context. Values <= 0 mean no limit."; |
| 23 | + type = types.int; |
| 24 | + default = 0; |
| 25 | + }; |
| 26 | + |
| 27 | + lineNumbers = mkOption { |
| 28 | + description = ""; |
| 29 | + type = types.bool; |
| 30 | + default = true; |
| 31 | + }; |
| 32 | + |
| 33 | + multilineThreshold = mkOption { |
| 34 | + description = "Maximum number of lines to collapse for a single context line."; |
| 35 | + type = types.int; |
| 36 | + default = 20; |
| 37 | + }; |
| 38 | + |
| 39 | + trimScope = mkOption { |
| 40 | + description = nvim.nmd.asciiDoc "Which context lines to discard if <<opt-vim.treesitter.context.maxLines>> is exceeded."; |
| 41 | + type = types.enum ["inner" "outer"]; |
| 42 | + default = "outer"; |
| 43 | + }; |
| 44 | + |
| 45 | + mode = mkOption { |
| 46 | + description = "Line used to calculate context."; |
| 47 | + type = types.enum ["cursor" "topline"]; |
| 48 | + default = "cursor"; |
| 49 | + }; |
| 50 | + |
| 51 | + separator = mkOption { |
| 52 | + description = nvim.nmd.asciiDoc '' |
| 53 | + Separator between context and content. Should be a single character string, like '-'. |
| 54 | +
|
| 55 | + When separator is set, the context will only show up when there are at least 2 lines above cursorline. |
| 56 | + ''; |
| 57 | + type = with types; nullOr str; |
| 58 | + default = null; |
| 59 | + }; |
| 60 | + |
| 61 | + zindex = mkOption { |
| 62 | + description = "The Z-index of the context window."; |
| 63 | + type = types.int; |
| 64 | + default = 20; |
| 65 | + }; |
15 | 66 | };
|
16 | 67 |
|
17 |
| - config = mkIf (cfg.enable && cfg.context.enable) { |
18 |
| - vim.startPlugins = [ |
19 |
| - "nvim-treesitter-context" |
20 |
| - ]; |
| 68 | + config = mkIf (treesitter.enable && cfg.enable) { |
| 69 | + vim.startPlugins = ["nvim-treesitter-context"]; |
21 | 70 |
|
22 | 71 | vim.luaConfigRC.treesitter-context = nvim.dag.entryAnywhere ''
|
23 |
| - -- Treesitter Context config |
24 | 72 | require'treesitter-context'.setup {
|
25 | 73 | enable = true,
|
26 |
| - throttle = true, |
27 |
| - max_lines = 0 |
| 74 | + max_lines = ${toString cfg.maxLines}, |
| 75 | + min_window_height = ${toString cfg.minWindowHeight}, |
| 76 | + line_numbers = ${boolToString cfg.lineNumbers}, |
| 77 | + multiline_threshold = ${toString cfg.multilineThreshold}, |
| 78 | + trim_scope = '${cfg.trimScope}', |
| 79 | + mode = '${cfg.mode}', |
| 80 | + separator = ${nvim.lua.nullString cfg.separator}, |
| 81 | + max_lines = ${toString cfg.zindex}, |
28 | 82 | }
|
29 | 83 | '';
|
30 | 84 | };
|
|
0 commit comments