irongit

My nvim configuration

feat: inline html treesitter for rust

huncholanehuncholaneauthored
parent c0f9b4ecommit aa1c4868cb01e3246aeb38ba85661e7a170b3703Browse files

2 files changed, +16 -0

+12-0after/queries/rust/injections.scm
@@ -0,0 +1,12 @@
1+; extends
2+
3+; Inject HTML into raw string literals preceded by a `// html` comment
4+(
5+ (line_comment) @_comment
6+ .
7+ (raw_string_literal
8+ (string_content) @injection.content)
9+ (#match? @_comment "//\\s*html")
10+ (#set! injection.language "html")
11+ (#set! injection.include-children)
12+)
+4-0lsp/rust.lua
@@ -167,6 +167,10 @@ return {
167167 navic.attach(client, bufnr)
168168 end
169169
170+ -- Disable semantic token "string" highlight for Rust so treesitter
171+ -- injections (// html raw string literals) are not overridden
172+ vim.api.nvim_set_hl(0, "@lsp.type.string.rust", {})
173+
170174 vim.api.nvim_buf_create_user_command(bufnr, "LspCargoReload", function()
171175 reload_workspace(bufnr)
172176 end, { desc = "Reload current cargo workspace" })