From 639a6e7545830602c09711b3757a28537baf8e75 Mon Sep 17 00:00:00 2001 From: Folke Lemaitre Date: Sun, 8 Oct 2023 13:45:54 +0200 Subject: [PATCH] feat(extra): add extra `util.dot` that configures multiple ft and treesitter langs when needed --- lua/lazyvim/plugins/extras/util/dot.lua | 62 +++++++++++++++++++++++++ 1 file changed, 62 insertions(+) create mode 100644 lua/lazyvim/plugins/extras/util/dot.lua diff --git a/lua/lazyvim/plugins/extras/util/dot.lua b/lua/lazyvim/plugins/extras/util/dot.lua new file mode 100644 index 00000000..159c9421 --- /dev/null +++ b/lua/lazyvim/plugins/extras/util/dot.lua @@ -0,0 +1,62 @@ +---@type string +local xdg_config = vim.env.XDG_CONFIG_HOME or vim.env.HOME .. "/.config" + +---@param path string +local function have(path) + return vim.loop.fs_stat(xdg_config .. "/" .. path) ~= nil +end + +return { + + -- Add Hyprland Parser + { + "luckasRanarison/tree-sitter-hypr", + enabled = have("hypr"), + event = "BufRead */hypr/*.conf", + config = function() + -- Fix ft detection for hyprland + vim.filetype.add({ + pattern = { [".*/hypr/.*%.conf"] = "hypr" }, + }) + require("nvim-treesitter.parsers").get_parser_configs().hypr = { + install_info = { + url = "https://github.com/luckasRanarison/tree-sitter-hypr", + files = { "src/parser.c" }, + branch = "master", + }, + filetype = "hypr", + } + end, + }, + + -- add some stuff to treesitter + { + "nvim-treesitter/nvim-treesitter", + opts = function(_, opts) + local function add(lang) + if type(opts.ensure_installed) ~= "table" then + table.insert(opts.ensure_installed, lang) + end + end + + vim.filetype.add({ + extension = { rasi = "rasi" }, + pattern = { + [".*/waybar/config"] = "jsonc", + [".*/mako/config"] = "dosini", + [".*/kitty/*.conf"] = "bash", + }, + }) + + add("git_config") + + if have("fish") then + add("fish") + end + + if have("rofi") or have("wofi") then + add("rasi") + end + end, + }, +}