plugins/treesitter: Add injections to highlight lua in nixvim options (#344)

This commit is contained in:
traxys 2023-04-21 20:29:33 +02:00 committed by GitHub
parent 5a498edd14
commit 9c8bee9da6
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 25 additions and 0 deletions

View file

@ -91,6 +91,10 @@ in {
default = {}; default = {};
description = "This is the configuration for extra modules. It should not be used directly"; description = "This is the configuration for extra modules. It should not be used directly";
}; };
nixvimInjections =
mkEnableOption
"nixvim specific injections, like lua highlighting in extraConfigLua";
}; };
}; };
@ -148,6 +152,20 @@ in {
require('nvim-treesitter.configs').setup(${helpers.toLuaObject tsOptions}) require('nvim-treesitter.configs').setup(${helpers.toLuaObject tsOptions})
''; '';
extraFiles = mkIf cfg.nixvimInjections {
"queries/nix/injections.scm" = ''
;; extends
(binding
attrpath: (attrpath (identifier) @_path)
expression: [
(string_expression (string_fragment) @lua)
(indented_string_expression (string_fragment) @lua)
]
(#match? @_path "^extraConfigLua(Pre|Post)?$"))
'';
};
extraPlugins = with pkgs; extraPlugins = with pkgs;
if cfg.nixGrammars if cfg.nixGrammars
then [(cfg.package.withPlugins (_: cfg.grammarPackages))] then [(cfg.package.withPlugins (_: cfg.grammarPackages))]

View file

@ -12,6 +12,13 @@
}; };
}; };
nixvimInjections = {
plugins.treesitter = {
enable = true;
nixvimInjections = true;
};
};
# This needs a custom input # This needs a custom input
# custom = { # custom = {
# plugins.treesitter = { # plugins.treesitter = {