svim is a Bash script designed to help you manage multiple configurations for Neovim. It allows you to create, switch between, and manage different Neovim configurations conveniently.
Copy script to /usr/local/bin
, and set executive permission
-c
: (Optional) Indicates that you want to create a new configuration.
-l
: (Optional) Lists all available configurations and displays the current configuration.
-r <config>
: (Optional) Removes the specified configuration after confirmation, provided it is not the current configuration.
config
: (Required) The name of the configuration you want to create, switch to, or remove.
To create a new Neovim configuration, use the -c
option followed by the name of the configuration:
svim -c <config_name>
Example:
svim -c myconfig
What It Does: Creates the following directories:
~/.config/nvim_<config_name>
~/.local/share/nvim_<config_name>
~/.cache/nvim_<config_name>
Creates symbolic links from these directories to the standard Neovim configuration directories:
~/.config/nvim
~/.local/share/nvim
~/.cache/nvim
Note
If any of the configuration directories already exist, the script will output an error message and exit without making changes.
To switch to an existing configuration, omit the -c option and provide the configuration name:
svim <config_name>
Example:
svim myconfig
What It Does:
Checks if the configuration directories exist:
~/.config/nvim_<config_name>
~/.local/share/nvim_<config_name>
~/.cache/nvim_<config_name>
If they exist, updates the symbolic links to point to these directories.
If any of the directories do not exist, the script outputs an error message and exits.
To list all available configurations and display the current one, use the -l
option:
svim -l
What It Does:
- Displays all configurations found in
~/.config/
with the prefixnvim_
. - Shows the currently active configuration if one is set.
To remove a specific configuration, use the -r
option followed by the configuration name:
svim -r <config_name>
What It Does:
- Prevents Deletion of Current Configuration: If the specified configuration is the currently active one, the script will inform you and prevent deletion.
- Prompts for confirmation by asking the user to enter the configuration name twice.
- Deletes the specified configuration directories if confirmed.
If the required config parameter is missing, the script will display usage information and exit.
When creating a new configuration with -c
, if the target configuration directories already exist, the script will inform you and terminate to prevent overwriting existing configurations.
When switching configurations without -c
, if the specified configuration directories do not exist, the script will notify you of the missing directories and exit.
When removing a configuration, if the specified configuration does not exist, the script will notify you and exit.
If you attempt to remove the current configuration, the script will inform you that it cannot be deleted and exit.
The script manages symbolic links for Neovim's configuration directories. It removes existing links before creating new ones to ensure they point to the correct configuration.
svim -c dev
Creates:
~/.config/nvim_dev
~/.local/share/nvim_dev
~/.cache/nvim_dev
Updates symbolic links to point to these new directories.
svim work
Updates symbolic links to point to:
~/.config/nvim_work
~/.local/share/nvim_work
~/.cache/nvim_work
svim -l
Output Example:
Available configurations:
dev
work
Current configuration: dev
svim -r myconfig
Output Example:
Are you sure you want to remove the configuration 'myconfig'? (type it twice to confirm)
Enter configuration name: myconfig
Confirm configuration name: myconfig
Configuration 'myconfig' has been removed.
svim -r dev
Output:
Error: You cannot delete the current configuration 'dev'. Please switch to another configuration first.
svim -c dev
Output:
Error: Configuration directories already exist.
svim simplifies the process of managing multiple Neovim configurations by automating the creation and switching of configuration directories through symbolic links. This allows for a seamless experience when working with different setups, such as development, testing, or personal projects.