From 46ee50eff4a5612bc075e68151c88b2856d67025 Mon Sep 17 00:00:00 2001 From: Robson Roberto Souza Peixoto Date: Tue, 17 Jan 2023 23:21:16 -0300 Subject: [PATCH 1/3] Configure packer_compiled.lua to be stored on XDG_DATA_DIRS The `packer_compiled.lua` use a lot of values that only works on the host where the file was compiled. Put the compiled file on XDG_DATA_DIRS make easier use ~/.config/nvim to both on Linux and Macos. --- init.lua | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/init.lua b/init.lua index ac291dad17a..c12a50dc07b 100644 --- a/init.lua +++ b/init.lua @@ -7,7 +7,23 @@ if vim.fn.empty(vim.fn.glob(install_path)) > 0 then vim.cmd [[packadd packer.nvim]] end -require('packer').startup(function(use) +-- Use a protected call so we don't error out on first use +local status_ok, packer = pcall(require, "packer") +if not status_ok then + return +end +local status_util_ok, util = pcall(require, "packer.util") +if not status_util_ok then + return +end + +-- Have packer use a popup window +packer.init({ + package_root = util.join_paths(vim.fn.stdpath('data'), 'site', 'pack'), + compile_path = util.join_paths(vim.fn.stdpath('data'), 'site', 'plugin', 'packer_compiled.lua'), +}) + +packer.startup(function(use) -- Package manager use 'wbthomason/packer.nvim' From 7881ea08439227fbda12d07c1fb3e6b8dbace53e Mon Sep 17 00:00:00 2001 From: Robson Roberto Souza Peixoto Date: Wed, 18 Jan 2023 09:44:27 -0300 Subject: [PATCH 2/3] refactor: rename variable from util to packer_util --- init.lua | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/init.lua b/init.lua index c12a50dc07b..369b235884c 100644 --- a/init.lua +++ b/init.lua @@ -12,15 +12,15 @@ local status_ok, packer = pcall(require, "packer") if not status_ok then return end -local status_util_ok, util = pcall(require, "packer.util") +local status_util_ok, packer_util = pcall(require, "packer.util") if not status_util_ok then return end -- Have packer use a popup window packer.init({ - package_root = util.join_paths(vim.fn.stdpath('data'), 'site', 'pack'), - compile_path = util.join_paths(vim.fn.stdpath('data'), 'site', 'plugin', 'packer_compiled.lua'), + package_root = packer_util.join_paths(vim.fn.stdpath('data'), 'site', 'pack'), + compile_path = packer_util.join_paths(vim.fn.stdpath('data'), 'site', 'plugin', 'packer_compiled.lua'), }) packer.startup(function(use) From 0bd31218dfc68d41c0c79d189acd4e0b40ffce0d Mon Sep 17 00:00:00 2001 From: Robson Roberto Souza Peixoto Date: Wed, 18 Jan 2023 09:49:09 -0300 Subject: [PATCH 3/3] refactor: rename status_util_ok to status_packer_util_ok --- init.lua | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/init.lua b/init.lua index 369b235884c..79b21606f99 100644 --- a/init.lua +++ b/init.lua @@ -12,8 +12,8 @@ local status_ok, packer = pcall(require, "packer") if not status_ok then return end -local status_util_ok, packer_util = pcall(require, "packer.util") -if not status_util_ok then +local status_packer_util_ok, packer_util = pcall(require, "packer.util") +if not status_packer_util_ok then return end