Skip to content

hyprland configuration files grammar for treesitter

Notifications You must be signed in to change notification settings

aserowy/tree-sitter-hypr

 
 

Repository files navigation

tree-sitter-hyprlang

hyprlang grammar for tree-sitter.

Neovim

To actually use it in Neovim and get syntax highlighting, folds, smart indent, and automatic file detection, you can use the repository as a plugin by installing it with your package manager. Then, install the grammar with :TSInstall hyprlang.

Lazy

return {
  "luckasRanarison/tree-sitter-hyprlang",
  dependencies = { "nvim-treesitter/nvim-treesitter" },
}

Packer

use {
  "luckasRanarison/tree-sitter-hyprlang",
  requires = { "nvim-treesitter/nvim-treesitter" },
}

Nix as flake

Add the flake and use it as vimPlugin within e.g. your home manager configuration for neovim.

{
  inputs = {
    nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable";
    home-manager = {
      url = "github:nix-community/home-manager";
      inputs.nixpkgs.follows = "nixpkgs";
    };
    tree-sitter-hyprlang = {
      url = "github:luckasRanarison/tree-sitter-hyprlang";
      inputs.nixpkgs.follows = "nixpkgs";
    };
  };
  outputs = {
    nixpkgs,
    home-manager,
    tree-sitter-hyprlang,
    ...
  }: {
    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-hyprlang.packages.${pkgs.system}.default
                {
                  plugin = nvim-treesitter.withAllGrammars;
                  type = "lua";
                  config = ''
                    require('nvim-treesitter.configs').setup({
                      highlight = { enable = true }
                    })
                  '';
                }
              ];
            };
          }
          # ...
        ];
      };
  };
}

Filetype detection

hyprlang does not have a specific filetype extension. Thus, we detect .conf with a path pattern. If your configuration does not get initialized as filetype hyprlang you can set it locally with :set filetype=hyprlang or add another pattern for type detection to your config. The following snippet resolves files with name hyprland.conf and sets hyprlang as filetype.

vim.filetype.add({
  pattern = { [".*/hyprland%.conf"] = "hyprlang" },
})

About

hyprland configuration files grammar for treesitter

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • JavaScript 44.3%
  • Nix 25.6%
  • Scheme 13.9%
  • Lua 8.9%
  • Python 7.3%