Skip to content

Commit

Permalink
Merge pull request #22 from ngalaiko/fix/readme-injections
Browse files Browse the repository at this point in the history
fix: add docs about injection for other langs
  • Loading branch information
qvalentin authored Oct 13, 2024
2 parents fd9e1c6 + e9ba1d0 commit cb370ff
Showing 1 changed file with 19 additions and 4 deletions.
23 changes: 19 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,13 +39,26 @@ More dialects could be added in the future (e.g. for html templates).
:TSInstall helm
```

### Highlighting for the templated language

To get proper highlighting for the language that is templated (e.g. html) you need to add injections for
that language to `.config/nvim/queries/gotmpl/injections.scm`:

```scm
((text) @injection.content
(#set! injection.language "html")
(#set! injection.combined))
```

Replace html with the tree-sitter name of your required language and make sure to install it with `:TSInstall`.

More advanced use cases would require adding more dialects (as done for helm).

> [!NOTE]
>
> If you are using helm, you should also install the yaml parser (:TSInstall yaml) to get [language injection][] for yaml
> [!TIP]
> If you are using helm, you should also install the yaml parser (:TSInstall yaml) to get [language injection][] for yaml.
>
> If you are using [AstroNvim][] you can just install the [astrocommunity][] helm pack.
> In case you are using [AstroNvim][] you can just install the [astrocommunity][] helm pack or when using [LazyVim][] its [LazyVimHelm] plugin.
[tree-sitter]: https://github.com/tree-sitter/tree-sitter
[Golang templates]: https://golang.org/pkg/text/template/
Expand All @@ -57,3 +70,5 @@ More dialects could be added in the future (e.g. for html templates).
[language injection]: https://tree-sitter.github.io/tree-sitter/syntax-highlighting#language-injection
[AstroNvim]: https://github.com/AstroNvim/AstroNvim
[astrocommunity]: https://github.com/AstroNvim/astrocommunity
[LazyVim]: https://www.lazyvim.org/
[LazyVimHelm]: https://github.com/LazyVim/LazyVim/blob/main/lua/lazyvim/plugins/extras/lang/helm.lua

0 comments on commit cb370ff

Please sign in to comment.