diff --git a/.gitignore b/.gitignore index 2c085d1..8eb57f9 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,3 @@ node_modules target +result diff --git a/README.md b/README.md index fb4de5a..5957abb 100644 --- a/README.md +++ b/README.md @@ -31,3 +31,55 @@ Packer: ```lua use { "luckasRanarison/tree-sitter-hypr" } ``` + +Nix: + +with a basic `flake.nix` and all treesitter grammars +```nix +{ + inputs = { + nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable"; + home-manager = { + url = "github:nix-community/home-manager"; + inputs.nixpkgs.follows = "nixpkgs"; + }; + tree-sitter-hypr = { + url = "github:luckasRanarison/tree-sitter-hypr"; + inputs.nixpkgs.follows = "nixpkgs"; + }; + }; + outputs = { + nixpkgs, + home-manager, + tree-sitter-hypr, + ... + }: { + homeConfigurations."user@hostname" = let + pkgs = nixpkgs.legacyPackages.x86_64-linux; + in + home-manager.lib.homeManagerConfiguration { + inherit pkgs; + modules = [ + { + programs.neovim = { + enable = true; + plugins = with pkgs.vimPlugins; [ + tree-sitter-hypr.packages.${pkgs.system}.default + { + plugin = nvim-treesitter.withAllGrammars; + type = "lua"; + config = '' + require('nvim-treesitter.configs').setup({ + highlight = { enable = true } + }) + ''; + } + ]; + }; + } + # ... + ]; + }; + }; +} +``` diff --git a/flake.lock b/flake.lock new file mode 100644 index 0000000..b79aca5 --- /dev/null +++ b/flake.lock @@ -0,0 +1,61 @@ +{ + "nodes": { + "flake-utils": { + "inputs": { + "systems": "systems" + }, + "locked": { + "lastModified": 1694529238, + "narHash": "sha256-zsNZZGTGnMOf9YpHKJqMSsa0dXbfmxeoJ7xHlrt+xmY=", + "owner": "numtide", + "repo": "flake-utils", + "rev": "ff7b65b44d01cf9ba6a71320833626af21126384", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "flake-utils", + "type": "github" + } + }, + "nixpkgs": { + "locked": { + "lastModified": 1700794826, + "narHash": "sha256-RyJTnTNKhO0yqRpDISk03I/4A67/dp96YRxc86YOPgU=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "5a09cb4b393d58f9ed0d9ca1555016a8543c2ac8", + "type": "github" + }, + "original": { + "owner": "NixOS", + "ref": "nixos-unstable", + "repo": "nixpkgs", + "type": "github" + } + }, + "root": { + "inputs": { + "flake-utils": "flake-utils", + "nixpkgs": "nixpkgs" + } + }, + "systems": { + "locked": { + "lastModified": 1681028828, + "narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=", + "owner": "nix-systems", + "repo": "default", + "rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e", + "type": "github" + }, + "original": { + "owner": "nix-systems", + "repo": "default", + "type": "github" + } + } + }, + "root": "root", + "version": 7 +} diff --git a/flake.nix b/flake.nix new file mode 100644 index 0000000..f7a8a23 --- /dev/null +++ b/flake.nix @@ -0,0 +1,44 @@ +{ + 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 = "v1.0.2"; + + hypr-grammar = pkgs.tree-sitter.buildGrammar { + language = "hypr"; + inherit version src; + generate = true; + }; + + in { + packages = { + default = pkgs.vimUtils.buildVimPlugin { + pname = "tree-sitter-hypr"; + 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.treesitter.language.require_language(\"hypr\", \"${hypr-grammar}/parser\") + ''; + in '' + echo "${tsInstall}" >> ./plugin/init.lua + ''; + }; + }; + }); +}