From 421277215f34d4804014d3fc2ddd14344c0248a7 Mon Sep 17 00:00:00 2001 From: Tiago Garcia Date: Thu, 18 Jul 2024 00:45:18 +0100 Subject: [PATCH] Colors fix Signed-off-by: Tiago Garcia --- .config/nvim/lua/tiagorg/colors.lua | 9 +++++++-- .config/nvim/lua/tiagorg/init.lua | 1 - 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/.config/nvim/lua/tiagorg/colors.lua b/.config/nvim/lua/tiagorg/colors.lua index 16beba2..99f4fa0 100644 --- a/.config/nvim/lua/tiagorg/colors.lua +++ b/.config/nvim/lua/tiagorg/colors.lua @@ -1,10 +1,14 @@ +local path = vim.fn.stdpath('config') +local absolute_path = vim.loop.fs_realpath(path) or path +local colorscheme_file = absolute_path .. "/data/colorscheme.txt" + local function trim(str) return str:gsub("^%s*(.-)%s*$", "%1") end function LoadColors() local color = nil - local file = io.open("/home/tiagorg/.dotfiles/.config/nvim/data/colorscheme.txt", "r") + local file = io.open(colorscheme_file, "r") -- check if file exists if file == nil then @@ -30,8 +34,9 @@ end function OnColorschemeChanged() local newColorscheme = vim.g.colors_name - local file = io.open("/home/tiagorg/.dotfiles/.config/nvim/data/colorscheme.txt", "w") + local file = io.open(colorscheme_file, "w+") if file == nil then + vim.loop.fs_mkdir(absolute_path .. "/data", 511, OnColorschemeChanged) return end file:write(newColorscheme) diff --git a/.config/nvim/lua/tiagorg/init.lua b/.config/nvim/lua/tiagorg/init.lua index 17a8b97..9bb77e9 100644 --- a/.config/nvim/lua/tiagorg/init.lua +++ b/.config/nvim/lua/tiagorg/init.lua @@ -6,4 +6,3 @@ require('tiagorg.colors') require('Comment').setup() require("nvim-surround").setup() -vim.g.nvim_config_path = vim.fn.stdpath('config')