diff --git a/lua/modules/configs/editor/rainbow_delims.lua b/lua/modules/configs/editor/rainbow_delims.lua index 650fd044a..037a81397 100644 --- a/lua/modules/configs/editor/rainbow_delims.lua +++ b/lua/modules/configs/editor/rainbow_delims.lua @@ -1,20 +1,25 @@ return function() - local function init_strategy() - local errors = 200 - vim.treesitter.get_parser():for_each_tree(function(lt) - if lt:root():has_error() and errors >= 0 then - errors = errors - 1 + local function init_strategy(check_lines) + return function() + local errors = 200 + vim.treesitter.get_parser():for_each_tree(function(lt) + if lt:root():has_error() and errors >= 0 then + errors = errors - 1 + end + end) + if errors < 0 then + return nil end - end) - if errors < 0 then - return nil + return (check_lines and vim.fn.line("$") > 450) and require("rainbow-delimiters").strategy["global"] + or require("rainbow-delimiters").strategy["local"] end - return require("rainbow-delimiters").strategy["local"] end vim.g.rainbow_delimiters = { strategy = { - [""] = init_strategy, + [""] = init_strategy(false), + c = init_strategy(true), + cpp = init_strategy(true), }, query = { [""] = "rainbow-delimiters",