Giter Club home page Giter Club logo

Comments (7)

windowsrefund avatar windowsrefund commented on August 19, 2024 1

This seems overly complicated and something that would never catch on. One of the reasons Astronvim is so nice is due to the fact it will look for override configs in ~/.config/astronvim/lua/user. As for multiple versions, I'm of the opinion that user config directory should just be managed as a git repo where you can test features in a feature branch as needed. That's a smarter and more efficient way to work than maintaining who knows how many copies of mostly redundant directories named $foo1, $foo2, etc, etc....

In summary, everything is already there in order to maintain a wall between the core files and the user config. If any automation were to be added, I'd think it's only purpose would be to setup a skeleton user config directory. There should be no need to throw anything into a user's ~/bin directory or stuff like that either.

from docs.

osamuaoki avatar osamuaoki commented on August 19, 2024

Hi,

As for installing AstroNvim off normal nvim runtimepath, we can document as follows:

$ mkdir -p ~/.config/avim
$ git clone   https://github.com/AstroNvim/AstroNvim.git ~/.config/avim
$ cat ~/bin/avim <<"EOF"
#!/bin/sh -e
# set up an alternative work environment
AVIM_PREFIX="avim"
XDG_CONFIG_HOME="$HOME/.config/$AVIM_PREFIX"
XDG_DATA_HOME="$HOME/.local/share/$AVIM_PREFIX"
NVIM_LOG_FILE="$HOME/.cache/$AVIM_PREFIX/log"
mkdir -p "$XDG_CONFIG_HOME"
mkdir -p "$XDG_DATA_HOME"
mkdir -p "${NVIM_LOG_FILE%/*}"
export XDG_CONFIG_HOME XDG_DATA_HOME NVIM_LOG_FILE
echo "$XDG_CONFIG_HOME"
echo "$XDG_DATA_HOME"
echo "${NVIM_LOG_FILE%/*}"
exec nvim "$@"
# vim:set ai et sw=2 ts=2 sts=2 tw=80:
EOF
$ chmod 755 ~/bin/avim
$ avim

In principle, the rest should be normal with file locations changed. (I assumed ~/bin is in $PATH)

At least, this is cleaner solution following exposed environment variables. (NO strange variables exported.)

The thing is I haven't used much. I don't know how some plugins are not well behaving. This needs to be tested.

from docs.

osamuaoki avatar osamuaoki commented on August 19, 2024

I realize, having multiple independent set-up is quite convenient, I whiped up an simple shell script. In order not to loose it, I am pasting it here. I now can have avi0 avi1, avi3, ... ;-)

#!/bin/sh -e
# AstroNvim installer for Unix-like environment
URL_GITHUB="https://github.com/AstroNvim/AstroNvim.git"
if [ -z "$1" ]; then
  echo "If you wish to create a name for NeoVim command as '<name>',"
  echo "Please run this program as '${0##*} <name>' ."
  exit 1
fi
NVIM_NAME="$1"
cd >/dev/null || true
HOME=$(pwd)
mkdir -p "$HOME/bin"
if [ -e "$HOME/bin/$NVIM_NAME" ]; then
  echo "$HOME/bin/$NVIM_NAME file(?) aleady exists.  Remove it first."
  exit 1
fi
if [ -e "$HOME/.config/$NVIM_NAME" ]; then
  echo "$HOME/.config/$NVIM_NAME directory(?) aleady exists.  Remove it first."
  exit 1
fi
if [ -e "$HOME/.local/share/$NVIM_NAME" ]; then
  echo "$HOME/.local/share/$NVIM_NAME directory(?) aleady exists.  Remove it first."
  exit 1
fi
if [ -e "$HOME/.cache/$NVIM_NAME" ]; then
  echo "$HOME/.cache/$NVIM_NAME directory(?) aleady exists.  Remove it first."
  exit 1
fi
# No preexisting installations, let's start
if [ "$NVIM_NAME" = "nvim" ]; then
  echo "Basic installation"
  mkdir -p "$HOME/.config"
  git clone "$URL_GITHUB" "$HOME/.config/nvim"
  mkdir -p "$HOME/.local/share/nvim"
  mkdir -p "$HOME/.cache"
else
  echo "Offset installation"
  mkdir -p "$HOME/.config/$NVIM_NAME"
  git clone "$URL_GITHUB" "$HOME/.config/$NVIM_NAME/nvim"
  mkdir -p "$HOME/.local/share/$NVIM_NAME/nvim"
  mkdir -p "$HOME/.cache/$NVIM_NAME"
cat > "$HOME/bin/$NVIM_NAME" << "EOF"
#!/bin/sh -e
# set up an alternative work environment for nvim
NVIM_NAME="${0##*/}"
XDG_CONFIG_HOME="$HOME/.config/$NVIM_NAME"
XDG_DATA_HOME="$HOME/.local/share/$NVIM_NAME"
NVIM_LOG_FILE="$HOME/.cache/$NVIM_NAME/log"
export XDG_CONFIG_HOME XDG_DATA_HOME NVIM_LOG_FILE
# shellcheck disable=SC2093
exec nvim "$@"
EOF
chmod 755 "$HOME/bin/$NVIM_NAME"
fi
# vim:set ai et sw=2 ts=2 sts=2 tw=80:

from docs.

osamuaoki avatar osamuaoki commented on August 19, 2024

I am a bit surprised by somewhat harsh criticism. But is it true?

I know and I use ~/.config/astronvim/lua/user. But that doesn't give us what OP said "Add recipe for users to have an installation similar to how LunarVim does things". They are meant for different usage cases.

LunarVim used to do quite intrusive vim RTP modification to do what it does. But now that NeoVim properly support XDG Base Directory Specification, we can use it now.

The script above is meant to be simpler approach by avoiding to make a exact replica of LunarVim script with the same file placement. (I also didn't use getopt nor trap to keep code simple.)

Having avim configured independently from the standard one installed in ~/.config/nvim/. and ~/.config/astronvim/ combination is useful. Configuration for avim as proposed above uses configuration in ~/.config/avim/nvim/. and ~/.config/avim/astronvim/ combination by setting XDG environment variable.

As for PR AstroNvim/AstroNvim#813 The script is made to be a bit more generic. So any good XDG repecting configuration setup such as NvChad can use this. (But not LunarVim)

from docs.

VonHeikemen avatar VonHeikemen commented on August 19, 2024

I made this lua script that can isolate AstroNvim environment, if used as an entrypoint it will allow you to have a config for AstroNvim and also a personal config for Neovim.

local path_sep = vim.loop.os_uname().version:match('Windows') and '\\' or '/'
local join = function(...) return table.concat({...}, path_sep) end
local getpath = function(arg)
  local path = vim.fn.stdpath(arg)
  return vim.fn.substitute(path, [[\(.*\)\zsnvim]], 'astronvim', '')
end

local data_path = getpath('data')
local astro_config = join(data_path, 'core')
local user_path = getpath('config')

vim.env.XDG_DATA_HOME = data_path
vim.env.XDG_CACHE_HOME = join(data_path, 'cache')
vim.env.XDG_STATE_HOME = join(data_path, 'state')

vim.opt.runtimepath = {
  user_path,
  astro_config,
  vim.env.VIMRUNTIME,
  join(astro_config, 'after'),
  join(user_path, 'after'),
}

vim.opt.packpath = {
  join(data_path, 'nvim', 'site'),
  user_path,
  vim.env.VIMRUNTIME
}

astronvim_installation = {home = astro_config}

local execute = loadfile(join(astro_config, 'init.lua'))

if not execute then
  vim.api.nvim_err_writeln("Could not load AstroNvim's init.lua")
  return
end

execute()
  • Clone AstroNvim in the same location the variable astro_config gives you.
git clone https://github.com/AstroNvim/AstroNvim ~/.local/share/astronvim/core
  • Create a configuration folder in the same location the variable user_path gives you.
mkdir -p ~/.config/astronvim
  • Copy the content of the script in your config folder.
~/.config/astronvim/entry.lua
  • Make an alias that uses the new entry point.
alias code='nvim -u ~/.config/astronvim/entry.lua'
  • Use the new command to open neovim with AstroNvim.

from docs.

mehalter avatar mehalter commented on August 19, 2024

I think we should put this in the documentation using the new NVIM_APPNAME feature that comes with Neovim v0.9 since that is the core neovim feature for doing this rather than us providing an arbitrary script.

from docs.

mehalter avatar mehalter commented on August 19, 2024

Added in latest commit to v4 branch

from docs.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.