Skip to content

A major mode for editing hyprland configuration files in emacs

License

Notifications You must be signed in to change notification settings

Nathan-Melaku/hyprlang-ts-mode

Repository files navigation

Emacs Tree-sitter Mode for Hyprlang

https://melpa.org/packages/hyprlang-ts-mode-badge.svg https://stable.melpa.org/packages/hyprlang-ts-mode-badge.svg

./screenshot-imenu.png

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.

Features

Currently, this mode provides the following features:

  • Syntax Highlighting
  • Proper Indentation Support
  • Navigation
  • Imenu

Requirements

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.

Installation

Follow these steps to install Hyprlang Tree-Sitter Mode:

  1. 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 press RET. This will install the hyperlang tree-sitter grammer.

  2. Install the hyprlang-ts-mode: hyperlang-ts-mode is available from MELPA. You can install it directly via M-x package-install RET hyprlang-ts-mode RET, after Enabling Melpa.

Configuration

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)

Usage

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.

About

A major mode for editing hyprland configuration files in emacs

Resources

License

Stars

Watchers

Forks

Packages

No packages published