From 7229abc7f323bb13bb02b8a5c74f6b9285562e45 Mon Sep 17 00:00:00 2001 From: Matthias Putz Date: Tue, 24 Mar 2026 22:19:48 +0100 Subject: [PATCH] treesitter: allow setting of treesitter max_lines to be string for percentage values --- docs/manual/release-notes/rl-0.9.md | 2 ++ modules/plugins/treesitter/ts-context/context.nix | 8 +++++--- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/docs/manual/release-notes/rl-0.9.md b/docs/manual/release-notes/rl-0.9.md index 3b77533d..71af5d55 100644 --- a/docs/manual/release-notes/rl-0.9.md +++ b/docs/manual/release-notes/rl-0.9.md @@ -444,5 +444,7 @@ https://github.com/gorbit99/codewindow.nvim - Add `vim.treesitter.indent.excludes` to exclude filetypes from the treesitter indentation; e.g. useful for Haskell and PureScript, for which treesitter indentation does not work good +- Allow `vim.treesitter.context.setupOpts.max_lines` to also be given as a + string in order to allow percentage values like `"20%"` diff --git a/modules/plugins/treesitter/ts-context/context.nix b/modules/plugins/treesitter/ts-context/context.nix index f6886f9c..6a009425 100644 --- a/modules/plugins/treesitter/ts-context/context.nix +++ b/modules/plugins/treesitter/ts-context/context.nix @@ -1,6 +1,6 @@ {lib, ...}: let inherit (lib.options) mkOption mkEnableOption; - inherit (lib.types) int bool str nullOr enum; + inherit (lib.types) int bool str nullOr enum either; inherit (lib.nvim.types) mkPluginSetupOption; inherit (lib.nvim.config) batchRenameOptions; migrationTable = { @@ -26,12 +26,14 @@ in { setupOpts = mkPluginSetupOption "treesitter-context" { max_lines = mkOption { - type = int; + type = either int str; default = 0; description = '' How many lines the window should span. - Values >= 0 mean there will be no limit. + Can be an absolute line number (given as int) or a percentage (given as string, e.g. "20%"). + + Values <= 0 mean there will be no limit. ''; };