diff options
author | Christian Clason <c.clason@uni-graz.at> | 2023-08-12 17:54:04 +0200 |
---|---|---|
committer | Christian Clason <c.clason@uni-graz.at> | 2023-08-14 00:14:35 +0200 |
commit | fc0ee871de2f56dbb80879c912203a6372c54e1c (patch) | |
tree | eb944a971daffb45b996d9f9083bfa0b40b43a39 /runtime/lua/vim/treesitter/languagetree.lua | |
parent | 006152ff7aa6af65a90c1f52962447ffca848dee (diff) | |
download | rneovim-fc0ee871de2f56dbb80879c912203a6372c54e1c.tar.gz rneovim-fc0ee871de2f56dbb80879c912203a6372c54e1c.tar.bz2 rneovim-fc0ee871de2f56dbb80879c912203a6372c54e1c.zip |
fix(treesitter)!: remove deprecated legacy injection format
Diffstat (limited to 'runtime/lua/vim/treesitter/languagetree.lua')
-rw-r--r-- | runtime/lua/vim/treesitter/languagetree.lua | 67 |
1 files changed, 4 insertions, 63 deletions
diff --git a/runtime/lua/vim/treesitter/languagetree.lua b/runtime/lua/vim/treesitter/languagetree.lua index b4c9027794..4b419c4744 100644 --- a/runtime/lua/vim/treesitter/languagetree.lua +++ b/runtime/lua/vim/treesitter/languagetree.lua @@ -769,65 +769,6 @@ function LanguageTree:_get_injection(match, metadata) return lang, combined, ranges end ----@private ----@param match table<integer,TSNode> ----@param metadata TSMetadata ----@return string, boolean, Range6[] -function LanguageTree:_get_injection_deprecated(match, metadata) - local lang = nil ---@type string - local ranges = {} ---@type Range6[] - local combined = metadata.combined ~= nil - - -- Directives can configure how injections are captured as well as actual node captures. - -- This allows more advanced processing for determining ranges and language resolution. - if metadata.content then - local content = metadata.content ---@type any - - -- Allow for captured nodes to be used - if type(content) == 'number' then - content = { match[content]:range() } - end - - if type(content) == 'table' and #content >= 4 then - vim.list_extend(ranges, content) - end - end - - local mlang = metadata.language - if mlang ~= nil then - assert(type(mlang) == 'string') - lang = mlang - end - - -- You can specify the content and language together - -- using a tag with the language, for example - -- @javascript - for id, node in pairs(match) do - local name = self._injection_query.captures[id] - - -- Lang should override any other language tag - if name == 'language' and not lang then - lang = vim.treesitter.get_node_text(node, self._source, { metadata = metadata[id] }) - elseif name == 'combined' then - combined = true - elseif name == 'content' and #ranges == 0 then - ranges[#ranges + 1] = vim.treesitter.get_range(node, self._source, metadata[id]) - -- Ignore any tags that start with "_" - -- Allows for other tags to be used in matches - elseif string.sub(name, 1, 1) ~= '_' then - if not lang then - lang = name - end - - if #ranges == 0 then - ranges[#ranges + 1] = vim.treesitter.get_range(node, self._source, metadata[id]) - end - end - end - - return lang, combined, ranges -end - --- Gets language injection points by language. --- --- This is where most of the injection processing occurs. @@ -852,11 +793,11 @@ function LanguageTree:_get_injections() self._injection_query:iter_matches(root_node, self._source, start_line, end_line + 1) do local lang, combined, ranges = self:_get_injection(match, metadata) - if not lang then - -- TODO(lewis6991): remove after 0.9 (#20434) - lang, combined, ranges = self:_get_injection_deprecated(match, metadata) + if lang then + add_injection(injections, index, pattern, lang, combined, ranges) + else + self:_log('match from injection query failed for pattern', pattern) end - add_injection(injections, index, pattern, lang, combined, ranges) end end |