Skip to content

Commit

Permalink
Adapt to new Neovim defaults in TS query API
Browse files Browse the repository at this point in the history
Fixes RRethy#41.

Adapted from a similar fix for nvim-treesitter:
nvim-treesitter/nvim-treesitter#7114
  • Loading branch information
metiulekm committed Oct 3, 2024
1 parent 8b34305 commit ad5ab41
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions lua/nvim-treesitter/endwise.lua
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ local M = {}
local indent_regex = vim.regex('\\v^\\s*\\zs\\S')
local tracking = {}

local query_opts = vim.fn.has "nvim-0.10" == 1 and { force = true, all = false } or true

local function tabstr()
if vim.bo.expandtab then
return string.rep(" ", vim.fn.shiftwidth())
Expand Down Expand Up @@ -133,7 +135,7 @@ local function endwise(bufnr)

local range = { root:range() }

for _, match, metadata in query:iter_matches(root, bufnr, range[1], range[3] + 1) do
for _, match, metadata in query:iter_matches(root, bufnr, range[1], range[3] + 1, query_opts) do
local indent_node, cursor_node, endable_node
for id, node in pairs(match) do
if query.captures[id] == 'indent' then
Expand Down Expand Up @@ -187,7 +189,7 @@ vim.treesitter.query.add_directive('endwise!', function(match, _, _, predicate,
metadata.endwise_end_node_type = predicate[4]
metadata.endwise_shiftcount = predicate[5] or 1
metadata.endwise_end_suffix_pattern = predicate[6] or '^.*$'
end)
end, query_opts)

vim.on_key(function(key)
if key ~= "\r" then return end
Expand Down

0 comments on commit ad5ab41

Please sign in to comment.