From 6e137fe9a3ee215f82a46a05e77be51ac17151f7 Mon Sep 17 00:00:00 2001 From: jdhao Date: Wed, 31 Jul 2024 01:08:50 +0200 Subject: [PATCH] make firenvim work again 1. fix build issue 2. fix PATH env issue --- lua/plugin_specs.lua | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/lua/plugin_specs.lua b/lua/plugin_specs.lua index 68d07d4..17de051 100644 --- a/lua/plugin_specs.lua +++ b/lua/plugin_specs.lua @@ -15,6 +15,12 @@ end vim.opt.rtp:prepend(lazypath) -- check if firenvim is active +-- macOS will reset the PATH when firenvim starts a nvim process, causing the PATH variable to change unexpectedly. +-- Here we are trying to get the correct PATH and use it for firenvim. +-- See also https://github.com/glacambre/firenvim/blob/master/TROUBLESHOOTING.md#make-sure-firenvims-path-is-the-same-as-neovims +local path_env = vim.env.PATH +local prologue = string.format('export PATH="%s"', path_env) + local firenvim_not_active = function() return not vim.g.started_by_firenvim end @@ -419,17 +425,13 @@ local plugin_specs = { { "glacambre/firenvim", enabled = function() - if vim.g.is_win or vim.g.is_mac then - return true - end - return false + local result = vim.g.is_win or vim.g.is_mac + return result end, - build = function() - vim.fn["firenvim#install"](0) - end, - lazy = true, + -- it seems that we can only call the firenvim function directly. + -- Using vim.fn or vim.cmd to call this function will fail. + build = string.format(":call firenvim#install(0, '%s')", prologue) }, - -- Debugger plugin { "sakhnik/nvim-gdb",