hyprlua-btw/readme.org
2026-05-13 13:42:48 -07:00

68 lines
1.7 KiB
Org Mode

#+TITLE: hyprlua-btw
#+AUTHOR: Tony, btw
Configuring Hyprland with Lua instead of Hyprlang.
* Why Lua?
Hyprland has historically been configured in Hyprlang, a custom DSL. Vaxry added Lua as an alternative because the project has outgrown the DSL.
Lua is a good fit:
- tiny and embeddable
- on basically every system
- ubiquitous tooling (syntax highlighting, LuaLS)
- you get a real LSP — completions, diagnostics, go-to-def — on your config
* Install on NixOS
Add Hyprland as a flake input:
#+begin_src nix
{
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
hyprland.url = "github:hyprwm/Hyprland/v0.55.0";
};
}
#+end_src
In =configuration.nix=:
#+begin_src nix
programs.hyprland = {
enable = true;
xwayland.enable = true;
package = inputs.hyprland.packages.${pkgs.system}.hyprland;
portalPackage = inputs.hyprland.packages.${pkgs.system}.xdg-desktop-portal-hyprland;
};
#+end_src
Install =lua-language-server= in your user packages so the LSP works.
* Lua config + LSP
Delete =~/.config/hypr/hyprland.conf=. Grab the Hyprland repo to pull the example Lua config and the LuaLS definitions:
#+begin_src sh
git clone --depth=1 https://github.com/hyprwm/Hyprland
cd Hyprland
nix develop
# generate the LuaLS type definitions
cd meta && python <gen-script>
# move generated defs + example config into ~/.config/hypr
#+end_src
Then drop a =.luarc.json= in =~/.config/hypr= so LuaLS picks up the =hl= global and the type definitions:
#+begin_src json
{
"workspace": {
"library": ["/home/tony/.config/hypr"]
},
"diagnostics": {
"globals": ["hl"]
}
}
#+end_src
Now you get full autocomplete and inline docs on every Hyprland keyword as you edit =hyprland.lua=.