Skip to content

Commit

Permalink
Fix #10
Browse files Browse the repository at this point in the history
  • Loading branch information
RRethy committed Feb 6, 2022
1 parent 92504a9 commit 59c8a6e
Showing 1 changed file with 30 additions and 0 deletions.
30 changes: 30 additions & 0 deletions lua/nvim-treesitter-endwise.lua
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
local queries = require("nvim-treesitter.query")

local M = {}

function M.init()
Expand All @@ -6,6 +8,34 @@ function M.init()
module_path = 'nvim-treesitter.endwise',
enable = false,
disable = {},
is_supported = function(lang)
if queries.has_query_files(lang, 'endwise') then
return true
end

local seen = {}
local function has_nested_endwise_language(nested_lang)
if seen[nested_lang] then
return false
end
seen[nested_lang] = true

if queries.has_query_files(lang, 'injections') then
local query = queries.get_query(lang, 'injections')
for _, capture in ipairs(query.info.captures) do
if capture == 'language'
or queries.has_query_files(lang, 'endwise')
or has_nested_endwise_language(lang) then
return true
end
end
end

return false
end

return has_nested_endwise_language(lang)
end,
}
}
end
Expand Down

0 comments on commit 59c8a6e

Please sign in to comment.