forked from tree-sitter-grammars/tree-sitter-hyprlang
-
Notifications
You must be signed in to change notification settings - Fork 0
/
flake.nix
53 lines (46 loc) · 1.3 KB
/
flake.nix
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
{
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
flake-utils.url = "github:numtide/flake-utils";
};
outputs = {
self,
nixpkgs,
flake-utils,
}:
flake-utils.lib.eachDefaultSystem (system: let
pkgs = import nixpkgs {
inherit system;
};
src = ./.;
version = "v2.0.0";
hyprlang-grammar = pkgs.tree-sitter.buildGrammar {
language = "hyprlang";
inherit version src;
generate = true;
};
in {
packages = {
default = pkgs.vimUtils.buildVimPlugin {
pname = "tree-sitter-hyprlang";
inherit version src;
# Since this package isn't with all the other treesitter grammars,
# we can simply add this line in the plugin to load it
preInstall = let
tsInstall = ''
vim.filetype.add({
pattern = { [\".*/hypr/.*%.conf\"] = \"hyprlang\" },
})
vim.api.nvim_create_autocmd(\"FileType\", {
pattern = \"hyprlang\",
callback = function(event) vim.bo[event.buf].commentstring = \"# %s\" end,
})
vim.treesitter.language.require_language(\"hyprlang\", \"${hyprlang-grammar}/parser\")
'';
in ''
echo "${tsInstall}" > ./plugin/init.lua
'';
};
};
});
}