diff --git a/plugin/filetypes.lua b/plugin/filetypes.lua index b52d3da3d..749fa2db4 100644 --- a/plugin/filetypes.lua +++ b/plugin/filetypes.lua @@ -22,7 +22,7 @@ local filetypes = { haskell_persistent = { 'haskellpersistent' }, idris = { 'idris2' }, janet_simple = { 'janet' }, - javascript = { 'javascriptreact', 'ecma', 'jsx', 'js' }, + javascript = { 'javascriptreact', 'ecma', 'ecmascript', 'jsx', 'js' }, javascript_glimmer = { 'javascript.glimmer' }, linkerscript = { 'ld' }, latex = { 'tex' }, diff --git a/plugin/query_predicates.lua b/plugin/query_predicates.lua index 06bf957f8..1a500f591 100644 --- a/plugin/query_predicates.lua +++ b/plugin/query_predicates.lua @@ -39,30 +39,3 @@ end, { force = true }) query.add_predicate('any-kind-eq?', function(match, _, _, pred) return predicates['kind-eq'](match, pred, true) end, { force = true }) - --- register custom directives - -local mimetype_aliases = { - ['importmap'] = 'json', - ['module'] = 'javascript', - ['application/ecmascript'] = 'javascript', - ['text/ecmascript'] = 'javascript', -} - ----@param match TSQueryMatch ----@param _ string ----@param bufnr integer ----@param pred string[] ----@return boolean|nil -query.add_directive('set-lang-from-mimetype!', function(match, _, bufnr, pred, metadata) - local id = pred[2] - local node = match[id] - local type_attr_value = vim.treesitter.get_node_text(node, bufnr, { metadata = metadata[id] }) - local configured = mimetype_aliases[type_attr_value] - if configured then - metadata['injection.language'] = configured - else - local parts = vim.split(type_attr_value, '/', {}) - metadata['injection.language'] = parts[#parts] - end -end, { force = true }) diff --git a/runtime/queries/html_tags/injections.scm b/runtime/queries/html_tags/injections.scm index 5b78e37b4..1c8ce012b 100644 --- a/runtime/queries/html_tags/injections.scm +++ b/runtime/queries/html_tags/injections.scm @@ -32,16 +32,40 @@ (#not-lua-match? @_no_type_lang "%stype%s*=") (#set! injection.language "javascript")) -; + + @@ -27,8 +29,6 @@ - - @@ -40,7 +40,7 @@ - +