-
Notifications
You must be signed in to change notification settings - Fork 27
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Format of embedded languages #2
Comments
I guess you meant to add Code <script lang="a">aaa</script>
<script lang="b">bbb</script> Query (script_element
(start_tag
(attribute
((attribute_name) @lang_key (#match? @lang_key "lang"))
((quoted_attribute_value) @lang_value (#match? @lang_value "a"))
)
)
(raw_text) @a
)
(script_element
(start_tag
(attribute
((attribute_name) @lang_key (#match? @lang_key "lang"))
((quoted_attribute_value) @lang_value (#match? @lang_value "b"))
)
)
(raw_text) @b
) Result (from the playground) |
Hello, I hope it's okay if I join in :) My main goal is to get Pug templates highlighted (at least a bit) but I can not get the individual parts matched. Code
Query
|
Hello there I've noticed some strange behaviour. It would be nice to get the highlighting not only for the selection. |
This query seems to work:
... next steps should be (for nvim integration, which @Artem-Schander and me seems to be after in the end) My findings up to now:
EDIT: Tested: When changing the @_lang in the query to a language known by treesitter, e.g. typescript, and also changing the template lang to ts, the highlighting works in general. So all the moving parts are there, Treesitter just does not know how to handle Pug files... |
I've implemented a pug tree parser and tried integrating it within neovim with Vue treeparser.
Otherwise, the content will be already processed and is not easily passed to the Pug parser as I figured out: |
@ikatyang Also, if you have any other ideas for better recognizing the language tag or adding more tests ... I would be happt for feedback, because I think the current implementation is suboptimal. @bjesus
Afterwards:
Or :TSInstallFromSource ... You might test it if it works with your files... |
@zealot128 I'd love to get it working but so far with no luck. I've followed the above steps but currently still no luck: Not sure what I missed. {
ensure_installed = {},
ignore_install = {},
modules = {
autopairs = {
disable = {},
enable = false,
module_path = "nvim-autopairs.internal"
},
highlight = {
additional_vim_regex_highlighting = false,
custom_captures = {},
disable = { "markdown" },
enable = true,
loaded = true,
module_path = "nvim-treesitter.highlight",
use_languagetree = true
},
incremental_selection = {
disable = {},
enable = false,
keymaps = {
init_selection = "gnn",
node_decremental = "grm",
node_incremental = "grn",
scope_incremental = "grc"
},
module_path = "nvim-treesitter.incremental_selection"
},
indent = {
disable = {},
enable = false,
module_path = "nvim-treesitter.indent"
}
},
update_strategy = "lockfile"
} Am I missing any step? |
@bjesus I dont know what you should do. But this is what I did.
And the following to .config/nvim/plugged/nvim-treesitter/queries/pug/highlights.scm
And the following to .config/nvim/plugged/nvim-treesitter/queries/pug/injections.scm
I got all these from comments made by @zealot128 on different github issues regarding this. |
Vue files can have a
script
element with eithertype="javascript"
(the default) ortype="typescript"
. It also support scripts in css, scss, less, sass and a few others.Would it be possible for the
script_element
andstyle_element
to somehow indicate the language of this embedded block? Or is that not something this parser can do?The text was updated successfully, but these errors were encountered: