From f34f19fae6e3fb05c3e6b6517d22792631af1984 Mon Sep 17 00:00:00 2001 From: nullchilly Date: Sat, 16 Jul 2022 12:30:46 +0700 Subject: [PATCH] fix(compiler): Missing is_windows --- README.md | 2 +- lua/catppuccin/init.lua | 2 +- lua/catppuccin/lib/compiler.lua | 18 ++++++------------ 3 files changed, 8 insertions(+), 14 deletions(-) diff --git a/README.md b/README.md index 9229161..f7216f6 100644 --- a/README.md +++ b/README.md @@ -355,7 +355,7 @@ vim.api.nvim_create_autocmd("User", { ```bash # It's recommended to add `:CatppuccinCompile` to post-install/update hooks Plug 'catppuccin/nvim', {'as': 'catppuccin', 'do': 'CatppuccinCompile'} -# Auto compile on save if catppuccin config is in `init.vim` +# Auto compile on save if catppuccin config is in init.vim autocmd BufWritePost init.vim :CatppuccinCompile ``` diff --git a/lua/catppuccin/init.lua b/lua/catppuccin/init.lua index 6b2e58b..4f63e92 100644 --- a/lua/catppuccin/init.lua +++ b/lua/catppuccin/init.lua @@ -40,7 +40,7 @@ function M.load() if config.compile.enabled == true then local compiled_path = config.compile.path - .. (vim.loop.os_uname().sysname == "Windows" and "\\" or "/") + .. (vim.startswith(vim.loop.os_uname().sysname, "Windows") and "\\" or "/") .. vim.g.catppuccin_flavour .. config.compile.suffix .. ".lua" diff --git a/lua/catppuccin/lib/compiler.lua b/lua/catppuccin/lib/compiler.lua index ac7f148..748dd5a 100644 --- a/lua/catppuccin/lib/compiler.lua +++ b/lua/catppuccin/lib/compiler.lua @@ -2,7 +2,7 @@ local M = {} -- Credit: https://github.com/EdenEast/nightfox.nvim local fmt = string.format -local sysname = vim.loop.os_uname().sysname +local is_windows = vim.startswith(vim.loop.os_uname().sysname, "Windows") local function inspect(t) local list = {} @@ -20,7 +20,7 @@ function M.compile() local lines = { [[ -- This file is autogenerated by CATPPUCCIN. --- Do not make changes directly to this file. +-- DO NOT make changes directly to this file. vim.cmd("hi clear") if vim.fn.exists("syntax_on") then @@ -29,7 +29,7 @@ end vim.g.colors_name = "catppuccin"]], } local config = require("catppuccin.config").options - if sysname == "Windows" or sysname == "Windows_NT" then + if is_windows then config.compile.path = config.compile.path:gsub("/", "\\") end @@ -73,16 +73,10 @@ vim.g.colors_name = "catppuccin"]], table.insert(lines, fmt('vim.g.%s = "%s"', k, v)) end end - os.execute( - string.format( - "mkdir %s %s", - (sysname == "Windows" or sysname == "Windows_NT") and "" or "-p", - config.compile.path - ) - ) + os.execute(string.format("mkdir %s %s", is_windows and "" or "-p", config.compile.path)) local file = io.open( config.compile.path - .. ((sysname == "Windows" or sysname == "Windows_NT") and "\\" or "/") + .. (is_windows and "\\" or "/") .. vim.g.catppuccin_flavour .. config.compile.suffix .. ".lua", @@ -95,7 +89,7 @@ end function M.clean() local config = require("catppuccin.config").options local compiled_path = config.compile.path - .. ((sysname == "Windows" or sysname == "Windows_NT") and "\\" or "/") + .. (is_windows and "\\" or "/") .. vim.g.catppuccin_flavour .. config.compile.suffix .. ".lua"