My nvim configuration
feat: inline html treesitter for rust
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 { | ||
| 167 | 167 | navic.attach(client, bufnr) |
| 168 | 168 | end |
| 169 | 169 | |
| 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 | + | |
| 170 | 174 | vim.api.nvim_buf_create_user_command(bufnr, "LspCargoReload", function() |
| 171 | 175 | reload_workspace(bufnr) |
| 172 | 176 | end, { desc = "Reload current cargo workspace" }) |