luckasRanarison / tree-sitter-hyprlang

hyprlang grammar for treesitter

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

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

hyprlang grammar for treesitter


Languages

Language:JavaScript 44.9%Language:Nix 25.3%Language:Scheme 13.8%Language:Lua 8.8%Language:Python 7.2%