From ae644feb7b67bf1ce4260c231d1d4300b19c6f30 Mon Sep 17 00:00:00 2001 From: pynappo Date: Thu, 1 Aug 2024 03:51:04 -0700 Subject: [PATCH] Add newer fallback method for tree-sitter scopes (#2006) --- lua/cmp/config/compare.lua | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/lua/cmp/config/compare.lua b/lua/cmp/config/compare.lua index f39921b..94c8028 100644 --- a/lua/cmp/config/compare.lua +++ b/lua/cmp/config/compare.lua @@ -212,7 +212,9 @@ compare.scopes = setmetatable({ -- Cursor scope. local cursor_scope = nil - for _, scope in ipairs(locals.get_scopes(buf)) do + -- Prioritize the older get_scopes method from nvim-treesitter `master` over get from `main` + local scopes = locals.get_scopes and locals.get_scopes(buf) or select(3, locals.get(buf)) + for _, scope in ipairs(scopes) do if scope:start() <= cursor_row and cursor_row <= scope:end_() then if not cursor_scope then cursor_scope = scope