Skip to content

Commit

Permalink
feat(rainbow_delims): line detections for c/cpp
Browse files Browse the repository at this point in the history
  • Loading branch information
Jint-lzxy committed Jul 17, 2023
1 parent d371fb4 commit ec24fef
Showing 1 changed file with 15 additions and 10 deletions.
25 changes: 15 additions & 10 deletions lua/modules/configs/editor/rainbow_delims.lua
Original file line number Diff line number Diff line change
@@ -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",
Expand Down

0 comments on commit ec24fef

Please sign in to comment.