Hyprlang Tree-Sitter Mode is a major mode designed to provide enhanced editing support for Hyprland configuration files in Emacs. By leveraging Tree-Sitter, this mode offers syntax highlighting and indentation, navigation, and imenu support.
Note
This package is based on Emacs 29’s built-in treesit
. And it
requires a tree-sitter-hyprlang grammer. The package has been tested
with version 3.0.0 of the tree-sitter-hyprlang grammer.
Currently, this mode provides the following features:
- Syntax Highlighting
- Proper Indentation Support
- Navigation
- Imenu
To use Hyprlang Tree-Sitter Mode, you’ll need the following:
- Emacs 29+ compiled with tree-sitter support
- A compatible Tree-Sitter grammar for Hyprland configuration files. You can find the grammer HERE. For more info look at the installation section below.
Follow these steps to install Hyprlang Tree-Sitter Mode:
- Get the hyprlang tree-sitter grammer: you can do this by adding the
tree-sitter grammer url to the
treesit-language-source-alist
alist(add-to-list 'treesit-language-source-alist '(hyprlang "https://github.com/tree-sitter-grammars/tree-sitter-hyprlang"))
Then
M-x
treesit-install-language-grammar
RET
. Then select hyperlang from the list and pressRET
. This will install the hyperlang tree-sitter grammer. - Install the hyprlang-ts-mode:
hyperlang-ts-mode
is available from MELPA. You can install it directly viaM-x package-install RET hyprlang-ts-mode RET
, after Enabling Melpa.
Indentation offset can be configured through a custom variable called
hyprlang-ts-mode-indent-offset
. By default it is set to 2 you can
change it to the value that suits you.
(use-package hyprlang-ts-mode
:ensure t
:custom
(hyprlang-ts-mode-indent-offset 4)
C-M-a
and C-M-e
will navigate to the begining and end of
sections. Imenu will show a list of sections available in the buffer.