-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: global install #1791
feat: global install #1791
Conversation
9e59335
to
153c7a2
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
One thing I'm not set on yet, should we call it LUNARVIM_ROOT_DIR
instead?
utils/bin/lvim
Outdated
#!/bin/sh | ||
#!/bin/bash |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please be aware that macOS is stuck with an ancient bash v3.xx.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Cool, I'll convert it to pure POSIX shell at the end of the PR.. just wanted to scratch up the idea quickly.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's probably because the default shell is ZSH
utils/bin/lvim
Outdated
# | ||
# When runnins as lvim the neovim process MUST never refer to the standard user config: | ||
# Anything that uses stdpath('data'), stdpath('cache') etc will get: | ||
# | ||
# LUNARVIM_x_DIR/nvim | ||
# | ||
export XDG_CONFIG_HOME=${LUNARVIM_CONFIG_DIR} | ||
export XDG_DATA_HOME="${LUNARVIM_RUNTIME_DIR}" | ||
export XDG_CACHE_HOME="${LUNARVIM_CACHE_DIR}" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Interesting, are you sure this actually works tho?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, I used this technique before LunarVim had the bootstrap in the configuration to remove and add folders from the runtimepath. Using just this, I was able to completely decouple a global install from the user's neovim config.
I think when I first did this, because its e.g. XDG_x_HOME/nvim for each folder the paths didn't make sense. (E.g. ~/.local/share/lunarvim/nvim ...).
However combined with the technique you've used already it works nicely.
I looked into the Neovim sources to work out how to do it, and it uses this variables, otherwise the defaults.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This might be risky now that I think about it. A lot of external tools are relying on these variables to read their configuration. If this environment variable is inherited by these tools then this will break a lot of stuff.
Could you test this with git
or lazygit
, and maybe something like fd
or ripgrep
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thats a good point, anything that forks from neovim will have those variables also..
I'll double check what happens..
I wonder if theres a way to unset those env variables for the nvim process once its running.
I can see in a terminal session thats the case.. I'll see if I can find anything.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok, so its simple in VIM... once running:
Simply execute the command e.g:
unlet $XDG_CONFIG_HOME
We could do this conditionally on init.
I suppose it kind of means we should also "push" these variables if they have already been set by the user, and pop them in the lvim init too.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've tested this, and unsetting XDG_x_HOME variables just causes vim.fn.stdpath() to return the standard values.
The environment variable must be evaluated everytime.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've tested this, and unsetting XDG_x_HOME variables just causes vim.fn.stdpath() to return the standard values. The environment variable must be evaluated everytime.
So that's a problem, because we also don't want to be missing with these variables as you never know the workflows that people are using. I think it's fine to leave them alone tbh. We have very little dependence on them outside of the cache
folder.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is also the approach I thought for solving #2944
Sadly, neovim does not provide any way to configure what those folders are and make that globally available for everyone, it's very frustrating to be honest.
It really matters because it not only relies on the cache, also the plugins installation place and the extensions state/storage is shared across neovim instances, which is a mess.
export LUNARVIM_RUNTIME_DIR="$HOME/.local/share/lunarvim/data" | ||
export LUNARVIM_CACHE_DIR="$HOME/.local/share/lunarvim/cache" | ||
export LUNARVIM_CONFIG_DIR="$HOME/.config/lvim" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why remove the default values check? It's useful in case the binary and installer get out of sync.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'll put that back in. (I actually didn't know what the syntax was doing)..
utils/bin/lvim
Outdated
# | ||
# Ensure a new install has an empty lvim/config.lua file | ||
# | ||
if [ ! -f ${LUNARVIM_CONFIG_DIR}/config.lua ]; then | ||
mkdir -p ${LUNARVIM_CONFIG_DIR} | ||
touch ${LUNARVIM_CONFIG_DIR}/config.lua | ||
fi | ||
|
||
# | ||
# If the global installation was updated, ensure to run a packer_sync | ||
# on the users installation. | ||
# | ||
if [ -v GLOBAL ]; then | ||
if [ ${LUNARVIM_INSTALL_DIR}/.packer_sync -nt ${LUNARVIM_RUNTIME_DIR}/.packer_sync ] || [ ! -f ${LUNARVIM_RUNTIME_DIR}/.packer_sync ]; then | ||
|
||
LUNARVIM_ARGS="+PackerSync" | ||
touch ${LUNARVIM_RUNTIME_DIR}/.packer_sync | ||
fi | ||
fi |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This part should be decoupled from the binary and handled by either the installer or the update handler.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
@@ -124,7 +124,7 @@ end | |||
---pulls the latest changes from github and, resets the startup cache | |||
function M:update() | |||
hooks.run_pre_update() | |||
M:update_repo() | |||
--M:update_repo() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why isn't this working?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have it commented on my branch because I'm using a global installation.
This means that the repo is at:
/usr/share/lunarvim or /opt/lunarvim.
Basically any user process doesn't have permission to git pull at that path.. and I want the other parts of LvimUpdate to succeed.
In a global install the admin would have to update Lvim's repo through...
sudo lvim +LvimUpdate
Or
pacman -Sy lvim
I'll look at update_repo() and make work gracefully on a system where the current user doesn't have permission.
bf869aa
to
f597c4f
Compare
I think we should make the following changes to the names: LUNARVIM_INSTALL_DIR -> LUNARVIM_ROOT_DIR or LUNARVIM_BASE_DIR @kylo252 Let me know what you think? |
Let's see if what I added in https://github.com/LunarVim/LunarVim/pull/1777/files/5c3ef594c65ce2396c2f114390c3061295fccfdf fixes the issue, then we won't have to introduce a new variable.
I'm slightly worried this might cause a regression since we haven't set a reliable way to update the binary. We would need to finish #1444 first, but that should fairly straight-forward anyway. |
I like what you are doing there. This is simpler, because the SHIM doesn't need to be updated unless you allow the user to choose an arbitrary base_dir. It defaults to using a global installation, unless the user has their own local installation, in-which case we use the users config... |
5cb4762
to
5bed5aa
Compare
For someone else waiting for it, here is a tricky way to do it. Put the following in your local home_dir = os.getenv("HOME")
local envs = {
LUNARVIM_CONFIG_DIR = home_dir .. "/.config/lvim",
LUNARVIM_RUNTIME_DIR = home_dir .. "/.local/share/lunarvim",
}
for key, val in pairs(envs) do
vim.fn.setenv(key, val)
end
local lvim_init = envs.LUNARVIM_RUNTIME_DIR .. "/lvim/init.lua"
vim.cmd("source " .. lvim_init) |
@meijieru, @jameswalmsley |
Thanks for the feature. |
Replaced by #3161 |
Resurrected my global-install PR again to work with the latest rolling release.
This ensures that bin/lvim defines all of the LUNARVIM_x_DIR variables correctly.
Also when running as lvim (instead of nvim) we should guarantee that stdpath('data') etc do not give paths to the user standard neovim installation.