mirror of
https://github.com/NotAShelf/nvf.git
synced 2026-04-26 11:29:54 +00:00
languages/jinja: add injection
This commit is contained in:
parent
e201640fc9
commit
10d7bb38ff
2 changed files with 30 additions and 6 deletions
|
|
@ -283,6 +283,9 @@
|
||||||
- Added {option}`vim.languages.tera.treesitter.injection` to configure, what
|
- Added {option}`vim.languages.tera.treesitter.injection` to configure, what
|
||||||
language the content is.
|
language the content is.
|
||||||
|
|
||||||
|
- Added {option}`vim.languages.jinja.treesitter.injection` to configure, what
|
||||||
|
language the content is.
|
||||||
|
|
||||||
- Added {option}`vim.treesitter.filetypeMappings` to support mappings similar to
|
- Added {option}`vim.treesitter.filetypeMappings` to support mappings similar to
|
||||||
<https://github.com/nvim-treesitter/nvim-treesitter/blob/main/plugin/filetypes.lua>.
|
<https://github.com/nvim-treesitter/nvim-treesitter/blob/main/plugin/filetypes.lua>.
|
||||||
This is mostly use full for Markdown code block injections.
|
This is mostly use full for Markdown code block injections.
|
||||||
|
|
|
||||||
|
|
@ -7,7 +7,7 @@
|
||||||
inherit (lib) genAttrs;
|
inherit (lib) genAttrs;
|
||||||
inherit (lib.modules) mkIf mkMerge;
|
inherit (lib.modules) mkIf mkMerge;
|
||||||
inherit (lib.options) literalExpression mkEnableOption mkOption;
|
inherit (lib.options) literalExpression mkEnableOption mkOption;
|
||||||
inherit (lib.types) enum listOf;
|
inherit (lib.types) enum listOf str;
|
||||||
inherit (lib.nvim.types) mkGrammarOption;
|
inherit (lib.nvim.types) mkGrammarOption;
|
||||||
|
|
||||||
cfg = config.vim.languages.jinja;
|
cfg = config.vim.languages.jinja;
|
||||||
|
|
@ -27,6 +27,11 @@ in {
|
||||||
};
|
};
|
||||||
package = mkGrammarOption pkgs "jinja";
|
package = mkGrammarOption pkgs "jinja";
|
||||||
inlinePackage = mkGrammarOption pkgs "jinja_inline";
|
inlinePackage = mkGrammarOption pkgs "jinja_inline";
|
||||||
|
injection = mkOption {
|
||||||
|
type = str;
|
||||||
|
default = "html";
|
||||||
|
description = "Treesitter language to inject in Jinja templates";
|
||||||
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
lsp = {
|
lsp = {
|
||||||
|
|
@ -46,11 +51,27 @@ in {
|
||||||
|
|
||||||
config = mkIf cfg.enable (mkMerge [
|
config = mkIf cfg.enable (mkMerge [
|
||||||
(mkIf cfg.treesitter.enable {
|
(mkIf cfg.treesitter.enable {
|
||||||
vim.treesitter.enable = true;
|
vim.treesitter = {
|
||||||
vim.treesitter.grammars = [
|
enable = true;
|
||||||
|
grammars = [
|
||||||
cfg.treesitter.package
|
cfg.treesitter.package
|
||||||
cfg.treesitter.inlinePackage
|
cfg.treesitter.inlinePackage
|
||||||
];
|
];
|
||||||
|
queries = [
|
||||||
|
{
|
||||||
|
type = "injections";
|
||||||
|
filetypes = ["jinja"];
|
||||||
|
query = ''
|
||||||
|
;; extends
|
||||||
|
|
||||||
|
((content) @injection.content
|
||||||
|
(#set! injection.language "${cfg.treesitter.injection}")
|
||||||
|
(#set! injection.combined)
|
||||||
|
)
|
||||||
|
'';
|
||||||
|
}
|
||||||
|
];
|
||||||
|
};
|
||||||
})
|
})
|
||||||
|
|
||||||
(mkIf cfg.lsp.enable {
|
(mkIf cfg.lsp.enable {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue