From e2a55628fc919fd98a286f731e742b3500468bf4 Mon Sep 17 00:00:00 2001 From: w1_liamby <55990985+WilliamBy@users.noreply.github.com> Date: Fri, 21 Jun 2024 21:21:18 +0800 Subject: [PATCH] feat(pack): add hyprlang config file language support (#1063) * feat(pack): add hyprland config file language support * Update lua/astrocommunity/pack/hyprland/init.lua Co-authored-by: Micah Halter * Update lua/astrocommunity/pack/hyprland/init.lua Co-authored-by: Micah Halter * Update lua/astrocommunity/pack/hyprland/init.lua Co-authored-by: Micah Halter * Update lua/astrocommunity/pack/hyprland/init.lua Co-authored-by: Micah Halter * Update lua/astrocommunity/pack/hyprland/README.md * Update lua/astrocommunity/pack/hyprland/README.md * Update lua/astrocommunity/pack/hyprland/README.md --------- Co-authored-by: Micah Halter --- lua/astrocommunity/pack/hyprlang/README.md | 15 +++++++ lua/astrocommunity/pack/hyprlang/init.lua | 52 ++++++++++++++++++++++ 2 files changed, 67 insertions(+) create mode 100644 lua/astrocommunity/pack/hyprlang/README.md create mode 100644 lua/astrocommunity/pack/hyprlang/init.lua diff --git a/lua/astrocommunity/pack/hyprlang/README.md b/lua/astrocommunity/pack/hyprlang/README.md new file mode 100644 index 000000000..06ace35a4 --- /dev/null +++ b/lua/astrocommunity/pack/hyprlang/README.md @@ -0,0 +1,15 @@ +# hyprlang Pack + +This plugin pack offers language support for Hyprland config file. It does the following: + +- Adds `hyprlang` filetype which will be assumed from below patterns: + - `*.hl` extension + - `.*/hypr/.*.conf`, `hypr.*.conf` +- Adds `hyprlang` Treesitter parsers + +## Requirement + +- Need to install `hyprls` tool first + - if (mason-tool-installer)[https://github.com/WhoIsSethDaniel/mason-tool-installer.nvim] has been loaded, then hyprls should be + installed automatically + - Execute `:Mason` to install hyprls via mason diff --git a/lua/astrocommunity/pack/hyprlang/init.lua b/lua/astrocommunity/pack/hyprlang/init.lua new file mode 100644 index 000000000..0b6f7506c --- /dev/null +++ b/lua/astrocommunity/pack/hyprlang/init.lua @@ -0,0 +1,52 @@ +---@type LazySpec +return { + -- mason ensure install hyprls + { + "WhoIsSethDaniel/mason-tool-installer.nvim", + optional = true, + opts = function(_, opts) + opts.ensure_installed = require("astrocore").list_insert_unique(opts.ensure_installed, { "hyprls" }) + end, + }, + + { + "AstroNvim/astrocore", + optional = true, + ---@type AstroCoreOpts + opts = { + -- add "hyprlang" file tpye + filetypes = { + extension = { + hl = "hyprlang", + }, + pattern = { + [".*/hypr/.*.conf"] = "hyprlang", + ["hypr.*.conf"] = "hyprlang", + }, + }, + }, + }, + { + "AstroNvim/astrolsp", + opts = function(_, opts) + local astrocore = require "astrocore" + opts.servers = astrocore.list_insert_unique(opts.servers, { "hyprls" }) + + return astrocore.extend_tbl(opts, { + config = { + hyprls = { filetypes = { "hyprlang" } }, + }, + }) + end, + }, + -- treesitter support for hyprlang + { + "nvim-treesitter/nvim-treesitter", + optional = true, + opts = function(_, opts) + if opts.ensure_installed ~= "all" then + opts.ensure_installed = require("astrocore").list_insert_unique(opts.ensure_installed, { "hyprlang" }) + end + end, + }, +}