A NVIM Plugin which applies inline language injections, when a string contains a comment with the language name.
use({"dariuscorvus/tree-sitter-language-injection.nvim", after="nvim-treesitter"})
require("tree-sitter-language-injection").setup()
When a string is found, and the first line is language specifc comment, for the desired language, followed by the language name, syntax highlighting gets applied.
as example we use the language typescript
and want that the string gets highlighted as sql
const select = `
--sql
SELECT * FROM user
WHERE active = 1
`;
which results in
When a comment is found above a variable, and starts with the name of the desired language, syntax highlighting gets applied.
as example we use the language typescript
and want that the string gets highlighted as sql
// sql
const select = `
SELECT * FROM user
WHERE active = 1
`;
which results in
- python
- comment inline
sql
surrealdb
- comment inline
- typescript
- comment inline
sql
surrealdb
- comment above
sql
surrealdb
- comment inline
- javascript
- comment inline
sql
surrealdb
- comment above
sql
surrealdb
- comment inline