Skip to content

Commit

Permalink
fix(deprecation): use query.get_files to avoid deprecation warning
Browse files Browse the repository at this point in the history
  • Loading branch information
theHamsta committed Mar 24, 2023
1 parent 582cbb5 commit f7b8e13
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
6 changes: 5 additions & 1 deletion lua/nvim-treesitter-textobjects.lua
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,11 @@ local utils = require "nvim-treesitter.utils"
local M = {}

M.has_textobjects = function(lang)
return vim.treesitter.query.get_query_files(lang, "textobjects") ~= nil
if vim.treesitter.query.get_files then --since nvim 0.9
return vim.treesitter.query.get_files(lang, "textobjects") ~= nil
else
return vim.treesitter.query.get_query_files(lang, "textobjects") ~= nil
end
end

local function has_some_textobject_mapping(lang)
Expand Down
4 changes: 3 additions & 1 deletion scripts/check-queries.lua
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,9 @@ local function do_check()
for _, lang in pairs(parsers) do
for _, query_type in pairs(query_types) do
print("Checking " .. lang .. " " .. query_type)
local query = vim.treesitter.query.get_query(lang, query_type)
-- get_query deprecated since nvim 0.9
local get_query = vim.treesitter.query.get or vim.treesitter.query.get_query
local query = get_query(lang, query_type)

if query then
for _, capture in ipairs(query.captures) do
Expand Down

0 comments on commit f7b8e13

Please sign in to comment.