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')