feat: remove obsolete directives

This commit is contained in:
Christian Clason 2023-08-11 17:07:47 +02:00
parent 8fb218dbfd
commit 776e1b599c
6 changed files with 10 additions and 44 deletions

View file

@ -45,31 +45,3 @@ query.add_directive('set-lang-from-mimetype!', function(match, _, bufnr, pred, m
metadata['injection.language'] = parts[#parts] metadata['injection.language'] = parts[#parts]
end end
end, true) 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)

View file

@ -3,5 +3,4 @@
(heredoc_template (heredoc_template
(template_literal) @injection.content (template_literal) @injection.content
(heredoc_identifier) @injection.language (heredoc_identifier) @injection.language)
(#downcase! @injection.language))

View file

@ -6,6 +6,5 @@
(#set! injection.language "xml")) (#set! injection.language "xml"))
(multiline_string (multiline_string
(multiline_string_type) @_lang (multiline_string_type) @injection.language
(multiline_string_content) @injection.content (multiline_string_content) @injection.content)
(#inject-language! @_lang))

View file

@ -1,8 +1,7 @@
(fenced_code_block (fenced_code_block
(info_string (info_string
(language) @_lang) (language) @injection.language)
(code_fence_content) @injection.content (code_fence_content) @injection.content)
(#inject-language! @_lang))
((html_block) @injection.content ((html_block) @injection.content
(#set! injection.language "html") (#set! injection.language "html")

View file

@ -5,17 +5,15 @@
((comment) @injection.content ((comment) @injection.content
(#set! injection.language "phpdoc")) (#set! injection.language "phpdoc"))
((heredoc (heredoc
(heredoc_body) @injection.content (heredoc_body) @injection.content
(heredoc_end) @injection.language (heredoc_end) @injection.language
(#set! injection.include-children) (#set! injection.include-children))
(#downcase! @injection.language)))
((nowdoc (nowdoc
(nowdoc_body) @injection.content (nowdoc_body) @injection.content
(heredoc_end) @injection.language (heredoc_end) @injection.language
(#set! injection.include-children) (#set! injection.include-children))
(#downcase! @injection.language)))
;; regex ;; regex

View file

@ -3,8 +3,7 @@
(heredoc_body (heredoc_body
(heredoc_content) @injection.content (heredoc_content) @injection.content
(heredoc_end) @injection.language (heredoc_end) @injection.language)
(#downcase! @injection.language))
(regex (regex
(string_content) @injection.content (string_content) @injection.content