mirror of
https://github.com/nvim-treesitter/nvim-treesitter.git
synced 2026-07-03 12:06:55 -04:00
feat: remove obsolete directives
This commit is contained in:
parent
8fb218dbfd
commit
776e1b599c
6 changed files with 10 additions and 44 deletions
|
|
@ -45,31 +45,3 @@ query.add_directive('set-lang-from-mimetype!', function(match, _, bufnr, pred, m
|
|||
metadata['injection.language'] = parts[#parts]
|
||||
end
|
||||
end, true)
|
||||
|
||||
query.add_directive('downcase!', function(match, _, bufnr, pred, metadata)
|
||||
local text, key, value ---@type string|string[], string, string|integer
|
||||
local id = pred[2]
|
||||
|
||||
if #pred == 3 then
|
||||
-- (#downcase! @capture "key")
|
||||
key = pred[3]
|
||||
value = metadata[id][key]
|
||||
else
|
||||
-- (#downcase! "key")
|
||||
key = id
|
||||
value = metadata[key]
|
||||
end
|
||||
|
||||
if type(value) == 'string' then
|
||||
text = value
|
||||
else
|
||||
local node = match[value]
|
||||
text = vim.treesitter.get_node_text(node, bufnr, { metadata = metadata[id] }) or ''
|
||||
end
|
||||
|
||||
if #pred == 3 then
|
||||
metadata[id][key] = string.lower(text)
|
||||
else
|
||||
metadata[key] = string.lower(text)
|
||||
end
|
||||
end, true)
|
||||
|
|
|
|||
|
|
@ -3,5 +3,4 @@
|
|||
|
||||
(heredoc_template
|
||||
(template_literal) @injection.content
|
||||
(heredoc_identifier) @injection.language
|
||||
(#downcase! @injection.language))
|
||||
(heredoc_identifier) @injection.language)
|
||||
|
|
|
|||
|
|
@ -6,6 +6,5 @@
|
|||
(#set! injection.language "xml"))
|
||||
|
||||
(multiline_string
|
||||
(multiline_string_type) @_lang
|
||||
(multiline_string_content) @injection.content
|
||||
(#inject-language! @_lang))
|
||||
(multiline_string_type) @injection.language
|
||||
(multiline_string_content) @injection.content)
|
||||
|
|
|
|||
|
|
@ -1,8 +1,7 @@
|
|||
(fenced_code_block
|
||||
(info_string
|
||||
(language) @_lang)
|
||||
(code_fence_content) @injection.content
|
||||
(#inject-language! @_lang))
|
||||
(language) @injection.language)
|
||||
(code_fence_content) @injection.content)
|
||||
|
||||
((html_block) @injection.content
|
||||
(#set! injection.language "html")
|
||||
|
|
|
|||
|
|
@ -5,17 +5,15 @@
|
|||
((comment) @injection.content
|
||||
(#set! injection.language "phpdoc"))
|
||||
|
||||
((heredoc
|
||||
(heredoc
|
||||
(heredoc_body) @injection.content
|
||||
(heredoc_end) @injection.language
|
||||
(#set! injection.include-children)
|
||||
(#downcase! @injection.language)))
|
||||
(#set! injection.include-children))
|
||||
|
||||
((nowdoc
|
||||
(nowdoc
|
||||
(nowdoc_body) @injection.content
|
||||
(heredoc_end) @injection.language
|
||||
(#set! injection.include-children)
|
||||
(#downcase! @injection.language)))
|
||||
(#set! injection.include-children))
|
||||
|
||||
;; regex
|
||||
|
||||
|
|
|
|||
|
|
@ -3,8 +3,7 @@
|
|||
|
||||
(heredoc_body
|
||||
(heredoc_content) @injection.content
|
||||
(heredoc_end) @injection.language
|
||||
(#downcase! @injection.language))
|
||||
(heredoc_end) @injection.language)
|
||||
|
||||
(regex
|
||||
(string_content) @injection.content
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue